docs: multiple event listeners on single node

It documents #2709
pull/2825/head
Emanuele 6 years ago committed by GitHub
parent 7ebf3477a4
commit cb5dcf2203
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -366,6 +366,23 @@ Components can emit events using [createEventDispatcher](docs#createEventDispatc
<SomeComponent on:whatever={handler}/> <SomeComponent on:whatever={handler}/>
``` ```
It's also possible to have two different listeners that react on the same event:
```html
<script>
let counter;
function increment() {
counter = counter + 1;
}
function track(event) {
trackEvent(event)
}
</script>
<button on:click="{increment}" on:click="{track}">Click me!</button>
```html
--- ---
As with DOM events, if the `on:` directive is used without a value, the component will *forward* the event, meaning that a consumer of the component can listen for it. As with DOM events, if the `on:` directive is used without a value, the component will *forward* the event, meaning that a consumer of the component can listen for it.

Loading…
Cancel
Save