Skip to content

Commit

Permalink
admin: Fix store race condition.
Browse files Browse the repository at this point in the history
  • Loading branch information
octavore committed Jun 3, 2018
1 parent 644fabf commit 9a1e272
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion admin/src/js/lib/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ export default class GenericStore<T> {

protected notify() {
Object.keys(this.subscribers).map((key) => {
this.subscribers[key](this.obj);
// check that the subscriber exists, because we may have removed
// the subscriber concurrently
let callback = this.subscribers[key];
if (callback) {
callback(this.obj);
}
});
}
}

0 comments on commit 9a1e272

Please sign in to comment.