Skip to content

Instantly share code, notes, and snippets.

@Westbrook
Created April 10, 2019 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Westbrook/5286281c0f541359e87f22c849f4bbb9 to your computer and use it in GitHub Desktop.
Save Westbrook/5286281c0f541359e87f22c849f4bbb9 to your computer and use it in GitHub Desktop.
import htm from 'https://unpkg.com/htm?module'; // for parity of renderer plus access to element properties
const handler = (e) => console.log("You've got an event at the parent level:",e);
const eventToComponent = htm`<MyComponent onSomething=${handler} />`;
const eventToCustomElement = htm`<my-component onSomething=${handler} />`;
// OR, you can use capturing to manage this sort of thing via central data store
document.body.addEventListener('something', e => {
e.stopPropagation();
console.log("You've got an event at the central data store level:",e);
// Do central data store stuff...
}, true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment