Skip to content

Commit

Permalink
add changeKey to Emitter
Browse files Browse the repository at this point in the history
  • Loading branch information
cinnamon-bun committed Sep 1, 2020
1 parent f9bb729 commit f1a07ea
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/util/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export class Emitter<T> {
// callback will run at a time, assuming the event is
// sent with "await send(...)" and not just "send(...)".
_callbacks : Callback<T>[] = [];
changeKey : number = 0; // this becomes a new random value with every update
constructor() {
}
subscribe(cb : Callback<T>) : Thunk {
Expand All @@ -19,6 +20,7 @@ export class Emitter<T> {
};
}
async send(t : T) : Promise<void> {
this.changeKey = Math.random();
for (let cb of this._callbacks) {
let result = cb(t);
if (result instanceof Promise) {
Expand Down

0 comments on commit f1a07ea

Please sign in to comment.