diff --git a/package/signal/README.md b/package/signal/README.md index bd6d2761f..c62bffdc5 100644 --- a/package/signal/README.md +++ b/package/signal/README.md @@ -200,14 +200,28 @@ Example: const listener = contentChangeSignal.addListener((content) => console.log(content)); ``` -### `removeListener(listener)` +### Listener API Interface + +#### `listener.disabled` + +Disable the listener, not called anymore. + +Example: + +```ts +const listener = contentChangeSignal.addListener((content) => console.log(content)); +... +listener.disabled = true; +``` + +#### `listener.remove()` Remove listener from specific signal. Example: ```ts -const listenerId = contentChangeSignal.addListener((content) => console.log(content)); +const listener = contentChangeSignal.addListener((content) => console.log(content)); ... -contentChangeSignal.removeListener(listenerId); +listener.remove(); ``` diff --git a/package/signal/src/signal.ts b/package/signal/src/signal.ts index a513ecc8b..cec544b30 100644 --- a/package/signal/src/signal.ts +++ b/package/signal/src/signal.ts @@ -249,12 +249,14 @@ export class ListenerInterface { } /** - * Disable signal, all dispatch's ignored (just value updated) and no more listeners will be called. + * Disable the listener, not called anymore. * * Example: * * ```ts - * contentChangeSignal.disabled = true; + * const listener = contentChangeSignal.addListener((content) => console.log(content)); + * ... + * listener.disabled = true; * ``` */ get disabled(): boolean {