Skip to content
This repository was archived by the owner on Feb 6, 2020. It is now read-only.

Latest commit

 

History

History
26 lines (19 loc) · 932 Bytes

File metadata and controls

26 lines (19 loc) · 932 Bytes

Using Providers

A Provider represents a source of asynchronous events. To subscribe to a Provider, you use it and pass it a block that will be called whenever there is an event to process.

component Main {
  state counter : Number = 0

  use Provider.Tick { 
    ticks = () : Promise(Never, Void) {
      next { counter = counter + 1 } 
    }
  }

  fun render : Html {
    <div>
      <{ Number.toString(counter) }>
    </div>
  }
}

In the above example we will update counter every second using the Tick Provider.

Other available Providers: AnimationFrame, Mouse and Scroll