Skip to content

Class: QueriesPlugin ​

Defined in: src/wirestate-core/plugin/queries/queries-plugin.ts:28

Enables query messaging on a container.

Remarks ​

Register it (new Container({ plugins: [new QueriesPlugin()] })) to bind the QueryBus and wire @OnQuery handlers at provision. Importing this class is what pulls the query bus into the bundle.

A child container can register its own QueriesPlugin for a local bus, or omit it to use the nearest ancestor bus.

Example ​

typescript
import { Container, QueriesPlugin, Injectable } from "@wirestate/core";

@Injectable()
class CartService {}

const container = new Container({ bindings: [CartService], plugins: [new QueriesPlugin()] });

Extends ​

  • MessagingPlugin

Constructors ​

Constructor ​

ts
new QueriesPlugin(): QueriesPlugin;

Defined in: src/wirestate-core/plugin/queries/queries-plugin.ts:29

Returns ​

QueriesPlugin

Overrides ​

ts
MessagingPlugin.constructor

Methods ​

install() ​

ts
install(container: Container): void;

Defined in: src/wirestate-core/plugin/messaging-plugin.ts:39

Contributes bindings (or other one-time setup) when the plugin is registered.

Parameters ​

ParameterTypeDescription
containerContainerContainer the plugin is registered on.

Returns ​

void

Remarks ​

Runs once, on the container the plugin is registered on (not on inheriting children), before any binding activates.

Register cleanup for install-time side effects with addRollback. Rollbacks run in reverse order if this or a later install throws, or if container construction fails afterwards. They are failsafe and do not run during normal container teardown.

Inherited from ​

ts
MessagingPlugin.install

onProvision() ​

ts
onProvision(
   instance: object, 
   container: Container, 
   addDisposer: (dispose: () => void) => void): void;

Defined in: src/wirestate-core/plugin/messaging-plugin.ts:57

Wires a provisioned instance, before any user @OnProvision.

Parameters ​

ParameterTypeDescription
instanceobjectThe provisioned instance.
containerContainerContainer being provisioned.
addDisposer(dispose: () => void) => voidRegisters a teardown callback for this provision cycle.

Returns ​

void

Remarks ​

Register teardown with addDisposer. Disposers run (reverse order, failsafe) at deprovision. A throw here unwinds the whole provision cycle.

Inherited from ​

ts
MessagingPlugin.onProvision

participates() ​

ts
participates(token: ServiceToken): boolean;

Defined in: src/wirestate-core/plugin/messaging-plugin.ts:47

Declares whether a binding token is a participant this plugin wires.

Parameters ​

ParameterTypeDescription
tokenServiceTokenBinding token to inspect.

Returns ​

boolean

Whether the plugin participates in this token.

Remarks ​

Token/class-level so it can drive force-activation: a token this returns true for is resolved (activated) at provision even if nothing injected it, and the instance is then delivered to WirestatePlugin.onProvision. Omit for a pure observer that force-activates nothing.

Inherited from ​

ts
MessagingPlugin.participates