@wirestate/react-signals [monorepo] [docs]
Re-exports @preact/signals-react for use with Wirestate services.
Installation
bash
npm install @wirestate/react-signals @preact/signals-reactFor a full Wirestate React + Signals app, install the core and React packages too:
bash
npm install @wirestate/core @wirestate/react @wirestate/react-signals @preact/signals-react reflect-metadataFor automatic component subscription without manual useSignal calls, add the Babel or SWC transform:
bash
npm install --save-dev @preact/signals-react-transformUsage
ts
import { signal, computed, effect, Signal, ReadonlySignal } from "@wirestate/react-signals";Example service:
ts
import { Injectable, Inject, WireScope } from "@wirestate/core";
import { signal, computed, Signal, ReadonlySignal } from "@wirestate/react-signals";
@Injectable()
export class CounterService {
public readonly count: Signal<number> = signal(0);
public readonly isEven: ReadonlySignal<boolean> = computed(() => this.count.value % 2 === 0);
public constructor(@Inject(WireScope) private scope: WireScope) {}
public increment(): void {
this.count.value++;
}
}License
MIT