Skip to content

RobotlegsJS/SignalsJS

This branch is 1 commit ahead of master.

Folders and files

NameName
Last commit message
Last commit date
Dec 4, 2019
May 22, 2021
May 22, 2021
May 22, 2021
May 22, 2021
Oct 5, 2018
Mar 18, 2019
May 22, 2021
Nov 17, 2018
Oct 27, 2016
May 22, 2021
Feb 10, 2020
Jul 18, 2019
May 22, 2021
Jul 25, 2018
Jun 11, 2021
Aug 15, 2019
May 22, 2021
Jul 28, 2018
Jul 26, 2018
May 22, 2021
Jul 20, 2022

Repository files navigation

Archived

This repository is archived. Development migrated to https://github.com/RobotlegsJS/RobotlegsJS-Framework/blob/master/packages/signals.

SignalsJS

GitHub license Gitter chat npm version 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!" });

SignalsJS for enterprise

Available as part of the Tidelift Subscription

The maintainers of @robotlegsjs/signals and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.

License

MIT