Skip to content

Instantly share code, notes, and snippets.

@mthadley
Created March 30, 2017 21:04
Show Gist options
  • Save mthadley/e01ce2e5de1172da01a7a968d86fc31f to your computer and use it in GitHub Desktop.
Save mthadley/e01ce2e5de1172da01a7a968d86fc31f to your computer and use it in GitHub Desktop.
/* Put this somewhere */
class PatrickStore extends EventEmitter {
closeContainer() {
this.emit('closeContainer');
}
openContainer() {
this.emit('openContainer');
}
}
window.store = new PatrickStore();
/* In Your Component */
class MyContainerThing extends Component {
created() {
this._handler = window.store.on('closeContainer', () => {
this.open = true;
});
}
disposed() {
this._handler.dispose();
}
}
/* Somewhere Else */
class OtherThing extends Component {
handleSomeClick_() {
window.store.openContainer();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment