Skip to content

API reference > @kontsedal/olas-core > PluginHooks

PluginHooks type ​

What setup returns. Every hook is optional. Observation hooks are synchronous and run after the change is visible to subscribers. A throw is isolated to its plugin and reported to the root's onError. None run once the root starts disposing.

Signature:

typescript
type PluginHooks = {
  onWrite?(event: WriteEvent): void;
  onInvalidate?(event: InvalidateEvent): void;
  onRemove?(event: RemoveEvent): void;
  onActivate?(event: ActivityEvent): void;
  onDeactivate?(event: ActivityEvent): void;
  onMutation?(event: MutationEvent): void;
  wrapFetch?(context: FetchContext, next: () => Promise<unknown>): Promise<unknown>;
  wrapMutate?(context: MutateContext, next: () => Promise<unknown>): Promise<unknown>;
  dispose?(): void;
};

References: WriteEvent, InvalidateEvent, RemoveEvent, ActivityEvent, MutationEvent, FetchContext, MutateContext

Released under the MIT License.