Public constructor (which should never be called).
A TypeError upon construction.
Overridden function binding the DispatchEffect to the
polymorphic this
of the StateWorker.
The explicit polymorphic this
parameter.
This DispatchEffect bound to the StateWorker.
Implanted DispatchEffect providing a convenient way to dispatch Store.Actions from within Store.Actions. This DispatchEffect in combination with the StateEffect can be used to implement complex interactions between different Stores.
The extending Store InstanceType.
The Bus.Handle representing the Store.
Rest
...action: Store.Action<T>A type-guarded Store.Action to dispatch.
The next Store.State after dispatching.
dispatch an Store.Action to another Store:
import { type Bus } from '@sgrud/bus';
import { Stateful, Store } from '@sgrud/state';
@Stateful('io.github.sgrud.store.example', { state: undefined })
export class ExampleStore extends Store<ExampleStore> {
public readonly state?: Store.State<Store>;
public async dispatchAction<T extends Store>(
handle: Bus.Handle,
...action: Store.Action<T>
): Promise<Store.State<this>> {
const state = await sgrud.state.effects.dispatch<T>(
handle, ...action
);
return { ...this, state };
}
}
Generated using TypeDoc
Built-in DispatchEffect extending the abstract Effect base class. This DispatchEffect is automatically StateWorker.implanted when the
@sgrud/state
module is imported and can therefore be always used in Store.Actions.Decorator
Implant
See
Effect