Document how to remove a component.$on listener

This PR documents how `component.$on` returns a function that removes the event listener when called.
pull/7738/head
Emil Tholin 7 years ago committed by GitHub
parent 529cf5c963
commit 800b2db4e6

@ -573,10 +573,14 @@ component.$on(event, callback)
Causes the `callback` function to be called whenever the component dispatches an `event`. Causes the `callback` function to be called whenever the component dispatches an `event`.
A function is returned that will remove the event listener when called.
```js ```js
app.$on('selected', event => { const off = app.$on('selected', event => {
console.log(event.detail.selection); console.log(event.detail.selection);
}); });
off();
``` ```
#### `$destroy` #### `$destroy`

Loading…
Cancel
Save