JSPM

type-signals

1.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 434
  • Score
    100M100P100Q92377F
  • License MIT

Small and fast Signal library for Typescript.

Package Exports

  • type-signals

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (type-signals) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Type Signals

Small and fast Signal library for Typescript.

Heavily inspired by mini-signals.

Install

npm install type-signals

Documentation

Example Usage

import { Signal } from 'type-signals';

type OnDoThingSignal = (foo: string, bar: string): void;
const mySignal = new Signal<OnDoThingSignal>();

const binding = mySignal.add(onSignal); // add listener
mySignal.dispatch('foo', 'bar');        // dispatch signal passing custom parameters
binding.detach();                       // remove a single listener

function onSignal(foo: string, bar: string)
{
    assert(foo === 'foo');
    assert(bar === 'bar');
}