Skip to content

Instantly share code, notes, and snippets.

@katelynsills
Last active January 27, 2019 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save katelynsills/26776804e41ef920b94d4486aef78f99 to your computer and use it in GitHub Desktop.
Save katelynsills/26776804e41ef920b94d4486aef78f99 to your computer and use it in GitHub Desktop.
We can rewrite the updateState method for our stateHolder such that it notifies the listeners asynchronously
updateState(newState) {
state = newState;
listeners.forEach(listener => {
Promise.resolve(listener).then(ev => ev.stateChanged(newState));
});
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment