Created
April 27, 2020 20:42
-
-
Save FelixLuciano/4a7e9fea56947bc913c7b37b7e2d9e8e to your computer and use it in GitHub Desktop.
Simple subscriber
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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