Gathering detailed insights and metrics for simplesignal
Gathering detailed insights and metrics for simplesignal
Gathering detailed insights and metrics for simplesignal
Gathering detailed insights and metrics for simplesignal
Super-simple signals (C#-style events) for JavaScript and TypeScript.
npm install simplesignal
Typescript
Module System
Node Version
NPM Version
JavaScript (80.99%)
TypeScript (19.01%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
10 Stars
109 Commits
1 Watchers
4 Branches
1 Contributors
Updated on Nov 15, 2024
Latest Version
6.0.0
Package Id
simplesignal@6.0.0
Unpacked Size
9.18 kB
Size
3.42 kB
File Count
6
NPM Version
10.2.3
Node Version
20.10.0
Published on
Jan 31, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
This is a super-simple signals class inspired by Robert Penner's AS3Signals.
Signals are like Events, Delegates, or Callbacks on other languages or platforms. You can create a signal that other parts of the code can "listen" to. When that signal is dispatched, all listeners are called with the passed parameters.
SimpleSignal is created with TypeScript, but aimed to be used as a standard JavaScript library.
1npm install simplesignal
First, import your signal:
1// Import (JavaScript ES5) 2var SimpleSignal = require('simplesignal'); 3 4// Import (JavaScript ES6 and TypeScript) 5import SimpleSignal from 'simplesignal';
Then, you can create a signal. For example, inside a class:
1public onSomethingHappened = new SimpleSignal();
Then other parts of the code can subscribe (listen) to that signal:
1myClassObject.onSomethingHappened.add((id) => { 2 console.log("Something happened with an id of " + id); 3});
Signals can then be dispatched with parameters:
1onSomethingHappened.dispatch("some-id");
This will call all subscribed functions with the given parameter.
1// Create 2onSomethingHappened = new SimpleSignal(); 3 4// Subscribe 5onSomethingHappened.add(myFunc); 6 7// Anonymous functions are, of course, fine 8onSomethingHappened.add(function() { ... }); 9onSomethingHappened.add(() => { ... }); 10 11// Unsubscribe 12onSomethingHappened.remove(myFunc); 13 14// Clear subscribers 15onSomethingHappened.removeAll(); 16 17// Number of subscribers 18console.log(onSomethingHappened.numItems); 19 20// Dispatch 21onSomethingHappened.dispatch(...args)
If your project already uses TypeScript, it has the advantage of using SimpleSignal's definition files for strict typing.
In this case, one can use a generic interface to enforce the correct dispatch/listener parameters:
1// Create, with a given interface as a Generic 2onSomethingHappened = new SimpleSignal<(action:string) => void>(); 3 4// The listeners must fulfill the interface 5function myFunc(action:string) { 6 console.log(action); 7} 8 9// Subscribe 10onSomethingHappened.add(myFunc); 11 12// Dispatch must also respect the interface 13onSomethingHappened.dispatch("some-action")
MIT.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
8 existing vulnerabilities detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More