Pages
Introduction
Getting Started
Recipes
Reference
Literals
Arrays
Tuples
Type System
Functions
Modules
Records
Enums
Built-in Types
Constants
Equality
Stores
Routing
Comments
Control Expressions
Components
Properties
Computed Properties
Styling Elements
Connecting Stores
Using Providers
Internal State
Referencing Entities
Global Components
Lifecycle Functions
Directives
JavaScript Interop
Environment Variables
Packages
Using Providers
A Provider represents a source of asynchronous events. To subscribe to a
Provider, you
use
it and pass it a record that contains the subscription data.
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: