kisrs 1.0.3 kisrs: ^1.0.3 copied to clipboard
Keep It Simple, Reactive State - A library for simplifying State management.
kisrs - Keep It Simple, Reactive State #
First, make a class for your state.
If your class has a dispose()
Function, it will be called on disposal.
class MyStore {
MyStore(){};
void dispose(){};
}
You can then attach an object of your class to a Store
or StoreManager
.
Store<T>
just passes your data down the Widget treeStoreManager<T>
contains a Store and automatically calls thedispose()
function when the Store is being disposed. Use this for cleanup.
You can access your Store with Store.of<T>(context)
.
DataPoint
s are how your store data in your state.
DataPoint<T>()
creates a new DataPoint of a givenT
ype that will benull
initially.DataPoint<T>.withValue()
creates a new DataPoint of a givenT
ype that contains initial data.
datapoint.value = 'Hello'
sets the value of datapoint
to 'Hello'
and sends the new value to the stream
.
datapoint.value
is the current value.
datapoint.stream
is is a stream of value changes. When you listen to it, it immediately sends the value.
datapoint.close()
releases the memory used for the DataPoint. You must do this in order to prevent memory leaks!