signus
v1.0.4
Published
Framework agnostic signals
Downloads
3
Maintainers
Readme
Signus
Framework agnostic signals.
Installation
> npm install signus
> yarn add signus
> pnpm add signus
Usage
You must create a SignalManager
instance and use it to create signals.
Example
import { SignalManager } from "signus";
const signalManager = new SignalManager();
const signal = signalManager.createSignal("mySignal");
signal.subscribe((value) => console.log(value));
signal.emit("Hello world");
Reuse a signal
If you want to reuse a signal, you can get it from the SignalManager
instance.
import signalManager from "./signalManager";
const signal = signalManager.getSignal("mySignal");
signal.subscribe((value) => console.log(value));
Remove a signal from the manager
You can remove a signal from the manager by calling the removeSignal
method.
signalManager.removeSignal("mySignal");
Remove a listener from a signal
You can remove a listener from a signal by calling the unsubscribe
method.
signal.unsubscribe();
License
MIT