@gluonjs/store / packages/store/src / StorePluginContext
Interface: StorePluginContext
Properties
definition
readonlydefinition:StorePluginDefinition
manager
readonlymanager:StoreManager
store
readonlystore:StorePluginStore
Example
Inspect the manager, definition, and live Store instance supplied when a Store plugin is installed:
import {
createStoreManager,
defineStore,
type DefineStoreOptions,
type StoreDefinition,
type StorePluginContext,
} from '@gluonjs/store';
type CounterState = { count: number };
type Empty = Record<never, never>;
const options = { id: 'counter', state: (): CounterState => ({ count: 0 }) } satisfies DefineStoreOptions<'counter', CounterState, Empty, Empty>;
const counter: StoreDefinition<'counter', CounterState, Empty, Empty> =
defineStore(options);
const manager = createStoreManager({
plugins: [(context: StorePluginContext) => {
console.log(`Mounted ${context.definition.id}`);
}],
});
const store = counter.use(manager);
store.$patch({ count: 1 });
manager.dispose();