diff --git a/site/content/docs/03-run-time.md b/site/content/docs/03-run-time.md index 843ac05e4c..0876cf3a36 100644 --- a/site/content/docs/03-run-time.md +++ b/site/content/docs/03-run-time.md @@ -573,10 +573,14 @@ component.$on(event, callback) 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 -app.$on('selected', event => { +const off = app.$on('selected', event => { console.log(event.detail.selection); }); + +off(); ``` #### `$destroy` diff --git a/site/content/tutorial/06-bindings/11-bind-this/text.md b/site/content/tutorial/06-bindings/11-bind-this/text.md index 25a7bc9169..e53b624057 100644 --- a/site/content/tutorial/06-bindings/11-bind-this/text.md +++ b/site/content/tutorial/06-bindings/11-bind-this/text.md @@ -2,7 +2,7 @@ title: This --- -The readonly `this` binding applies to every element (and component) and allows to you obtain a reference to rendered elements. For example, we can get a reference to a `` element: +The readonly `this` binding applies to every element (and component) and allows you to obtain a reference to rendered elements. For example, we can get a reference to a `` element: ```html ``` -Note that the value of `canvas` will be `undefined` until the component has mounted, so we put the logic inside the `onMount` [lifecycle function](tutorial/onmount). \ No newline at end of file +Note that the value of `canvas` will be `undefined` until the component has mounted, so we put the logic inside the `onMount` [lifecycle function](tutorial/onmount). diff --git a/site/content/tutorial/10-transitions/07-local-transitions/text.md b/site/content/tutorial/10-transitions/07-local-transitions/text.md index 7a22967ab0..400fbcaacb 100644 --- a/site/content/tutorial/10-transitions/07-local-transitions/text.md +++ b/site/content/tutorial/10-transitions/07-local-transitions/text.md @@ -4,7 +4,7 @@ title: Local transitions Ordinarily, transitions will play on elements when any container block is added or destroyed. In the example here, toggling the visibility of the entire list also applies transitions to individual list elements. -Instead, we'd like transitions to play only when individual items are added and removed — on other words, when the user drags the slider. +Instead, we'd like transitions to play only when individual items are added and removed — in other words, when the user drags the slider. We can achieve this with a *local* transition, which only plays when the immediate parent block is added or removed: @@ -12,4 +12,4 @@ We can achieve this with a *local* transition, which only plays when the immedia
{item}
-``` \ No newline at end of file +``` diff --git a/site/src/template.html b/site/src/template.html index a3b79ae1e8..db0c7ae395 100644 --- a/site/src/template.html +++ b/site/src/template.html @@ -2,7 +2,7 @@ - + %sapper.base%