Skip to content

@wirestate/core [monorepo] [docs]

npmlicense

Framework-agnostic Wirestate runtime.

Use this package to define injectable services, create containers, run lifecycle hooks, and communicate through container-local events, commands, and queries.

Install

bash
npm install @wirestate/core

Start

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

@Injectable()
class CounterService {
  public count: number = 0;

  public increment(): void {
    this.count++;
  }
}

const container = new Container({
  bindings: [CounterService],
});

const counterService = container.get(CounterService);

counterService.increment();

What Is Included

  • DI primitives such as Injectable, inject, Container, ServiceToken, and InjectionToken.
  • Container and container methods such as bind, unbind, unbindAll, get, has, and getOwnBindings.
  • OnActivation, OnDeactivation, OnProvision, and OnDeprovision.
  • WireStatus and ProvisionId for lifecycle guards on resolved service instances.
  • EventBus, CommandBus, QueryBus, and their decorators (OnEvent, OnCommand, OnQuery), enabled by registering EventsPlugin, CommandsPlugin, or QueriesPlugin.
  • An optional @wirestate/core/devtools subpath (DevToolsPlugin) for development-time container inspection.

React and Lit integration live in @wirestate/react and @wirestate/lit.

Learn More

License

MIT