FutureSignal
Future signals can be created by extension or method.
futureSignal
toSignal()
.value, .peek()
Returns AsyncState<T>
for the value and can handle the various states.
The value
getter returns the value of the future if it completed successfully.
.peek() can also be used to not subscribe in an effect
.reset()
The reset
method resets the future to its initial state to recall on the next evaluation.
.refresh()
Refresh the future value by setting isLoading
to true, but maintain the current state (AsyncData, AsyncLoading, AsyncError).
.reload()
Reload the future 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 future 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 futureSignal
to reset
every time any signal in the dependency array changes.