Motivation
This method returns current status of effect as store with string enumeration.
It is useful to show correct state of process in UI.
- When
status
is run, set defaultValue
value to $status
- When
effect
is called, set pending
status.
- When
effect
is succeeded, set done
status.
- When
effect
is failed, set fail
status.
Arguments
effect
(Effect<P, R>)
— any effect, that you need to watch status
defaultValue
('initial' | 'pending' | 'done' | 'fail')
optional — when $status
initializes, set initial value for it. By default value is "initial"
Returns
$status
(Store<'initial' | 'pending' | 'done' | 'fail'>)
— Store that saves current state of the effects
Note: use can manually reset status, just use $status.reset(event)
Example
Successful effect call changing status to “done”
Initial status
Clear (reset) status