StreamSignal
Stream signals can be created by extension or method.
streamSignal
toSignal()
.value, .peek()
Returns AsyncState<T>
for the value and can handle the various states.
The value
getter returns the value of the stream if it completed successfully.
.peek() can also be used to not subscribe in an effect
.reset()
The reset
method resets the stream to its initial state to recall on the next evaluation.
.refresh()
Refresh the stream value by setting isLoading
to true, but maintain the current state (AsyncData, AsyncLoading, AsyncError).
.reload()
Reload the stream value by setting the state to AsyncLoading
and pass in the value or error as data.
Dependencies
By default the callback will be called once and the stream will be cached unless a signal is read in the callback.
If there are signals that need to be tracked across an async gap then use the dependencies
when creating the streamSignal
to reset
every time any signal in the dependency array changes.