// The State will be the type of data you want to manipulate. interfaceState { authors: string[] }
// The Actions are a record of "action name" to a parameter. // If the action doesn't require a parameter, use `void`. typeActions = { 'add author': string 'action that doesnt need a parameter': void }
// To get the best out of this API, pass the Actions type and State // during construction. constsubject = newStatefulSubject<Actions, State>( { __INIT__: () => ({ authors: [] }),
Another form of the :class that reduces a piece of state with actions and queues changes to the stream.
It's important to note that if the result of an action does not change the state then nothing is queued to the stream.
See
:function
Example