Skip to content

Instantly share code, notes, and snippets.

@FelixLuciano
Created April 27, 2020 20:42
Show Gist options
  • Save FelixLuciano/4a7e9fea56947bc913c7b37b7e2d9e8e to your computer and use it in GitHub Desktop.
Save FelixLuciano/4a7e9fea56947bc913c7b37b7e2d9e8e to your computer and use it in GitHub Desktop.
Simple subscriber
class Subscriber {
constructor () {
this.subscribers = [];
}
subscribe (subscription) {
this.subscribers.push(subscription);
}
notifyAll (...data) {
this.subscribers.forEach(subscriber => subscriber(...data));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment