Skip to content

Instantly share code, notes, and snippets.

@leocristofani
Created December 19, 2018 12:58
Show Gist options
  • Save leocristofani/1f9df8fe861dd6581946068352f15fd8 to your computer and use it in GitHub Desktop.
Save leocristofani/1f9df8fe861dd6581946068352f15fd8 to your computer and use it in GitHub Desktop.
Micro-frontends in practice - communication between services via custom DOM events - subscribe
class SongsContainer extends React.Component {
componentDidMount() {
window.addEventListener(ARTISTS_SELECT_ARTIST, this.fetchSongs);
this.fetchSongs({ detail: { artist: this.state.artist } });
}
componentWillMount() {
window.removeEventListener(ARTISTS_SELECT_ARTIST, this.fetchSongs);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment