Lit-element: [docs] Define, fire, & listen for custom events

Created on 23 Jan 2019  路  4Comments  路  Source: Polymer/lit-element

Searched through documentation but didn't find any clue.
It should be pretty obvious I guess?
How can I define an event in my custom element, so that I can use it like
<my-custom-element @my-event=${this.myEventHandler} /> ?
Thank you very much!

docs

Most helpful comment

To be fixed in #413

All 4 comments

CustomEvent does what you need. You can find more info here: https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent
But some pseudo code to get you started:

fireEvent() {
this.dispatchEvent(newCustomEvent('my-event');
}

@Christian24 It works! Thank you very much! =D

To be fixed in #413

Fixed in #413.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  3Comments

LRagji picture LRagji  路  5Comments

quentin29200 picture quentin29200  路  3Comments

sorvell picture sorvell  路  3Comments

mercmobily picture mercmobily  路  3Comments