Skip to content

Instantly share code, notes, and snippets.

@coltpini
Created May 5, 2017 18:40
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 coltpini/5d4a67e88cad10b8e2577ab8133b0d91 to your computer and use it in GitHub Desktop.
Save coltpini/5d4a67e88cad10b8e2577ab8133b0d91 to your computer and use it in GitHub Desktop.
const someReallyAwesomeFunction = () => {
//some process that you want to know when it is finished in an async way.
//After we are finished with the process, then we can push an event
// with custom events we can attach what ever data we need to pass.
let myEvent = new CustomEvent('customEventName', {
detail: {
obj: 'that you can pass with the event!',
pass: 'what ever you want'
},
// stick your options here
bubbles: true,
cancelable: false
};
this.dispatchEvent(myEvent);
};
// Events follow the capture and bubble flow, so you can't know if it isn't attached to something in that flow.
someobj.addEventListener('customeEventName', (e) => console.log(e.detail) );
@d5e
Copy link

d5e commented Apr 21, 2021

line:21 custom*e*EventName

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment