Skip to content
TypeScript port of AS3 Signals
TypeScript JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
.vscode
dist
src
test
.auditignore
.editorconfig
.gitignore
.istanbul.yml
.prettierrc
.publishrc
.travis.yml
CHANGELOG.md
LICENSE
README.md
karma.conf.js
package.json
tsconfig.json
tsconfig.test.json
tslint.json
tslint.test.json
webpack.config.js
yarn.lock

README.md

SignalsJS

GitHub license Gitter chat Build Status codebeat badge Maintainability Test Coverage npm version Greenkeeper badge styled with prettier

SignalsJS is a TypeScript port of AS3 Signals. 15KB compressed.

About

Signals are light-weight, strongly-typed messaging tools. Wire your application with better APIs and less boilerplate than normal event systems.

Concept

  • A Signal is essentially a mini-dispatcher specific to one event, with its own array of listeners.
  • A Signal gives an event a concrete membership in a class.
  • Listeners subscribe to real objects, not to string-based channels.
  • Event string constants are no longer needed.
  • Signals was originally implemented by Robert Penner in AS3.
  • Signals are inspired by C# events and signals/slots in Qt.

Syntax

// with DOM EventListener
button.addEventListener("click", onClick);

// Signal equivalent; past tense is recommended
button.clicked.add(onClicked);

Installation

You can get the latest release and the type definitions using NPM:

npm install @robotlegsjs/signals

Or using Yarn:

yarn add @robotlegsjs/signals

Usage

import { Signal } from "@robotlegsjs/signals";

let signal = new Signal();

signal.add(data => {
    console.log(data.message);
});

signal.dispatch({ message: "hello signal!" });

License

MIT

You can’t perform that action at this time.