JSPM

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

A simple and very fast signal class.

Package Exports

  • mani-signal

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 (mani-signal) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

mani-signal

a simple and very fast signal class

Build

$ npm install
$ npm run build

Test

$ npm run test

Usage

$ npm install mani-signal --save

without parameter

import {Signal} from 'mani-signal';

const signal = new Signal();

signal.add(()=> {
    console.log('signal callback');
});

signal.dispatch();

with parameter

import {Signal} from 'mani-signal';

const signal = new Signal<string>();

signal.add(param => {
    console.log(`signal callback with ${param}`);
});

signal.dispatch('hello world');

listen once

import {Signal} from 'mani-signal';

const signal = new Signal();

signal.addOnce(() => {
    console.log(`will be called once`);
});

signal.dispatch();
signal.dispatch();

detach listener

import {Signal} from 'mani-signal';

const signal = new Signal();

const binding = signal.add(() => {
    console.log(`won't be called`);
});

binding.detach();

signal.dispatch();

detach all

import {Signal} from 'mani-signal';

const signal = new Signal();

signal.add(() => {
    console.log(`won't be called`);
});
signal.add(() => {
    console.log(`won't be called`);
});

signal.detachAll();

signal.dispatch();