Skip to content

Instantly share code, notes, and snippets.

@leocristofani
Created December 19, 2018 12:43
Show Gist options
  • Save leocristofani/7e488dc88b56702276fb539b1ae6b8b4 to your computer and use it in GitHub Desktop.
Save leocristofani/7e488dc88b56702276fb539b1ae6b8b4 to your computer and use it in GitHub Desktop.
Micro-frontends in practice - communication between services via custom DOM events - publish
// ...
class ArtistsListItem extends React.Component {
onClick = (e) => {
//...
window.dispatchEvent(
new CustomEvent(ARTISTS_SELECT_ARTIST, { detail: { artist: name } })
);
}
render() {
// ...
return (
<button onClick={this.onClick}>{name}</button>
);
}
}
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment