Socket
Book a DemoInstallSign in
Socket

ste-signals

Package Overview
Dependencies
Maintainers
1
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ste-signals

Add the power of Signals to your projects. They are the most bare bones implementation of an event.

3.0.11
latest
Source
npmnpm
Version published
Weekly downloads
5.6K
-16.44%
Maintainers
1
Weekly downloads
 
Created
Source

Strongly Typed Events - Signals

Signals are the most barebone of all events. They don't contain any data. They just invoke the registered handler.

Build Status npm version License: MIT

Subscription made easy

An example says more than a 1000 words. Imagine if you have events like this on your class:

let clock = new Clock("Smu", 1000);

//log the ticks to the console - this is a signal event
clock.onTick.subscribe(() => console.log("Tick!"));

Events made easy

So let's look at the implementation from a TypeScript perspective. (Do you program NodeJs without typescript? Check this)

import { SignalDispatcher } from "ste-signals";

class Clock {
  private _onTick = new SignalDispatcher();
  private _ticks: number = 0;

  constructor(public name: string, timeout: number) {
    setInterval(() => {
      this._ticks += 1;
      this._onTick.dispatch();
    }, timeout);
  }

  public get onTick() {
    return this._onTick.asEvent();
  }
}

Check the documentation or the examples for more information.

Need more info? Check the repo.

Maintenance

This project is maintained by Kees C. Bakker.

Keywords

signals

FAQs

Package last updated on 09 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.