Created
March 30, 2017 21:04
-
-
Save mthadley/e01ce2e5de1172da01a7a968d86fc31f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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