Skip to content

Instantly share code, notes, and snippets.

@durran
Created March 12, 2019 14:24
Show Gist options
  • Save durran/fb5c0ce7a549cb0343fc804d7c12c780 to your computer and use it in GitHub Desktop.
Save durran/fb5c0ce7a549cb0343fc804d7c12c780 to your computer and use it in GitHub Desktop.
Unsubscribe App Registry
class TextWriteButton extends React.Component {
/**
* Instantiate the component.
*
* @param {Object} props - The properties.
*/
constructor(props) {
super(props);
this.boundNamespaceChanged = this.namespaceChanged.bind(this);
}
/**
* Subscribe to the state changing stores.
*/
componentDidMount() {
global.hadronApp.appRegistry.on('namespace-changed', this.boundNamespaceChanged);
this.unsubscribeWriteState = WriteStateStore.listen(this.writeStateChanged.bind(this));
}
/**
* Unsubscribe from the stores.
*/
componentWillUnmount() {
global.hadronApp.appRegistry.off('namespace-changed', this.boundNamespaceChanged);
this.unsubscribeWriteState();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment