mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-06 13:40:16 +08:00
added observable util
This commit is contained in:
parent
e3ca8a131e
commit
d92df51a27
1 changed files with 13 additions and 0 deletions
13
frontend/src/js/util/observable.js
Normal file
13
frontend/src/js/util/observable.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
export default class Observable {
|
||||
Observable() {
|
||||
this.subscribers = [];
|
||||
}
|
||||
|
||||
subscribe(fn) {
|
||||
this.subscribers.push(fn);
|
||||
}
|
||||
|
||||
fire(params) {
|
||||
this.subscribers.forEach((fn) => fn(params));
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue