Class Effect<K>Abstract

Abstract Effect base class. When this class is extended and decorated with the Implant decorator or StateWorker.implanted through the StateHandler, its function will be made available to Store.Actions through the global sgrud.state.effects namespace.

Example

An importScripts Effect:

import { Effect, Implant, type StateWorker, type Store } from '@sgrud/state';

declare global {
namespace sgrud.state.effects {
function importScripts(...urls: (string | URL)[]): Promise<void>;
}
}

⁠@Implant('importScripts')
export class FetchEffect extends Effect {

public override function(
this: StateWorker
): Store.Effects['importScripts'] {
return async(...urls) => {
return importScripts(...urls);
};
}

}

Type Parameters

Hierarchy (view full)

Constructors

Methods

Constructors

Methods

Generated using TypeDoc