
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
signal-slot-js
Advanced tools
Signal/Slot pattern implemented in TypeScript.
No dependency, small (only 4ko in mignified mode) and efficient library.
We try to follow the Qt syntax for the connection, i.e., connect(sender, signal, receiver, slot).
Slot can be any method from a class, a setter, an arrow function or any function with any number of arguments.
Allows to connect/disconnect and lock/unlock connections
npm i signal-slot-js
or from the sources
git checkout git@github.com:xaliphostes/signal-slot-js.git
npm install
npm run build
Require node version > 11
npm run test
All examples are in the examples directory. Run them using ts-node
The following example shows how to implement the combineLatest from RxJS.
It will create the following:
task1 ---\
---> CombineLatest --> task3
rask2 ---/
task3 is launched only when task1 AND task2 are done.
import {create, emit, connect} from 'signal-slot'
// ----------------------------------------------
class Task {
constructor(public name: string, public ms: number) {
// Create a signal for this class
create(this, 'finished')
}
run() {
console.log(`Task ${this.name} is running for ${this.ms}ms...`)
// Emit a signal
setTimeout( () => emit(this, 'finished'), this.ms)
}
}
// ----------------------------------------------
// Will be executed when task1 AND task2 are done
class CombineLatest {
private doneTask1 = false
private doneTask2 = false
constructor(private task1: Task, private task2: Task) {
// Create a signal for this class
create(this, 'done')
// Perform two connections
connect({sender: task1, signal: 'finished', receiver: () => this.doneTask(1)})
connect({sender: task2, signal: 'finished', receiver: () => this.doneTask(2)})
}
private doneTask(n: number) {
console.log('done doing task', n)
switch(n) {
case 1: this.doneTask1 = true; break
case 2: this.doneTask2 = true; break
}
if (this.doneTask1 && this.doneTask2) {
console.log('doing task combine')
this.doneTask1 = false
this.doneTask2 = false
// Emit a signal
emit(this, 'done')
}
}
}
// ----------------------------------------------
const task1 = new Task('task 1', 500)
const task2 = new Task('task 2', 3000)
const combine = new CombineLatest(task1, task2)
// Perform a connection
connect({
sender: combine,
signal: 'done',
receiver: () => console.log('All done!')
})
// Run the 2 tasks in parallel and trigger combine
// when both are done
task1.run()
task2.run()
MIT License
FAQs
Signal-Slot à la Qt
We found that signal-slot-js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

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.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.