From 876539f78b522d3e5eb4828ab1fac41b56695854 Mon Sep 17 00:00:00 2001 From: nazar-lazarchuk Date: Wed, 26 Jan 2022 19:40:22 +0200 Subject: [PATCH] `count` variable revert --- .../07-stores/00-writable-stores/App.svelte | 10 +++++----- .../00-writable-stores/Decrementer.svelte | 4 ++-- .../00-writable-stores/Incrementer.svelte | 4 ++-- .../00-writable-stores/Resetter.svelte | 4 ++-- .../07-stores/00-writable-stores/stores.js | 2 +- .../01-auto-subscriptions/App.svelte | 4 ++-- .../01-auto-subscriptions/Decrementer.svelte | 4 ++-- .../01-auto-subscriptions/Incrementer.svelte | 4 ++-- .../01-auto-subscriptions/Resetter.svelte | 4 ++-- .../07-stores/01-auto-subscriptions/stores.js | 2 +- .../07-stores/04-custom-stores/App.svelte | 10 +++++----- .../07-stores/04-custom-stores/stores.js | 4 ++-- .../01-writable-stores/app-a/App.svelte | 10 +++++----- .../app-a/Decrementer.svelte | 2 +- .../app-a/Incrementer.svelte | 2 +- .../01-writable-stores/app-a/Resetter.svelte | 2 +- .../01-writable-stores/app-a/stores.js | 2 +- .../01-writable-stores/app-b/App.svelte | 10 +++++----- .../app-b/Decrementer.svelte | 4 ++-- .../app-b/Incrementer.svelte | 4 ++-- .../01-writable-stores/app-b/Resetter.svelte | 4 ++-- .../01-writable-stores/app-b/stores.js | 2 +- .../08-stores/01-writable-stores/text.md | 8 ++++---- .../02-auto-subscriptions/app-a/App.svelte | 10 +++++----- .../app-a/Decrementer.svelte | 4 ++-- .../app-a/Incrementer.svelte | 4 ++-- .../app-a/Resetter.svelte | 4 ++-- .../02-auto-subscriptions/app-a/stores.js | 2 +- .../02-auto-subscriptions/app-b/App.svelte | 4 ++-- .../app-b/Decrementer.svelte | 4 ++-- .../app-b/Incrementer.svelte | 4 ++-- .../app-b/Resetter.svelte | 4 ++-- .../02-auto-subscriptions/app-b/stores.js | 2 +- .../08-stores/02-auto-subscriptions/text.md | 20 +++++++++---------- .../05-custom-stores/app-a/App.svelte | 10 +++++----- .../05-custom-stores/app-a/stores.js | 4 ++-- .../05-custom-stores/app-b/App.svelte | 10 +++++----- .../05-custom-stores/app-b/stores.js | 4 ++-- .../08-stores/05-custom-stores/text.md | 4 ++-- 39 files changed, 100 insertions(+), 100 deletions(-) diff --git a/site/content/examples/07-stores/00-writable-stores/App.svelte b/site/content/examples/07-stores/00-writable-stores/App.svelte index 7c04e439a3..61e55401a5 100644 --- a/site/content/examples/07-stores/00-writable-stores/App.svelte +++ b/site/content/examples/07-stores/00-writable-stores/App.svelte @@ -1,17 +1,17 @@ -

The counter is {counterValue}

+

The count is {countValue}

diff --git a/site/content/examples/07-stores/00-writable-stores/Decrementer.svelte b/site/content/examples/07-stores/00-writable-stores/Decrementer.svelte index 2456344c56..043b795047 100644 --- a/site/content/examples/07-stores/00-writable-stores/Decrementer.svelte +++ b/site/content/examples/07-stores/00-writable-stores/Decrementer.svelte @@ -1,8 +1,8 @@ diff --git a/site/content/examples/07-stores/00-writable-stores/Incrementer.svelte b/site/content/examples/07-stores/00-writable-stores/Incrementer.svelte index 8274287742..2b5763012b 100644 --- a/site/content/examples/07-stores/00-writable-stores/Incrementer.svelte +++ b/site/content/examples/07-stores/00-writable-stores/Incrementer.svelte @@ -1,8 +1,8 @@ diff --git a/site/content/examples/07-stores/00-writable-stores/Resetter.svelte b/site/content/examples/07-stores/00-writable-stores/Resetter.svelte index 8882e35d57..4183421e51 100644 --- a/site/content/examples/07-stores/00-writable-stores/Resetter.svelte +++ b/site/content/examples/07-stores/00-writable-stores/Resetter.svelte @@ -1,8 +1,8 @@ diff --git a/site/content/examples/07-stores/00-writable-stores/stores.js b/site/content/examples/07-stores/00-writable-stores/stores.js index cdd10e573b..143e0c99f0 100644 --- a/site/content/examples/07-stores/00-writable-stores/stores.js +++ b/site/content/examples/07-stores/00-writable-stores/stores.js @@ -1,3 +1,3 @@ import { writable } from 'svelte/store'; -export const counter = writable(0); \ No newline at end of file +export const count = writable(0); \ No newline at end of file diff --git a/site/content/examples/07-stores/01-auto-subscriptions/App.svelte b/site/content/examples/07-stores/01-auto-subscriptions/App.svelte index fe24d27c4e..10ebfb65bb 100644 --- a/site/content/examples/07-stores/01-auto-subscriptions/App.svelte +++ b/site/content/examples/07-stores/01-auto-subscriptions/App.svelte @@ -1,11 +1,11 @@ -

The counter is {$counter}

+

The count is {$count}

diff --git a/site/content/examples/07-stores/01-auto-subscriptions/Decrementer.svelte b/site/content/examples/07-stores/01-auto-subscriptions/Decrementer.svelte index 2456344c56..043b795047 100644 --- a/site/content/examples/07-stores/01-auto-subscriptions/Decrementer.svelte +++ b/site/content/examples/07-stores/01-auto-subscriptions/Decrementer.svelte @@ -1,8 +1,8 @@ diff --git a/site/content/examples/07-stores/01-auto-subscriptions/Incrementer.svelte b/site/content/examples/07-stores/01-auto-subscriptions/Incrementer.svelte index 8274287742..2b5763012b 100644 --- a/site/content/examples/07-stores/01-auto-subscriptions/Incrementer.svelte +++ b/site/content/examples/07-stores/01-auto-subscriptions/Incrementer.svelte @@ -1,8 +1,8 @@ diff --git a/site/content/examples/07-stores/01-auto-subscriptions/Resetter.svelte b/site/content/examples/07-stores/01-auto-subscriptions/Resetter.svelte index 8882e35d57..4183421e51 100644 --- a/site/content/examples/07-stores/01-auto-subscriptions/Resetter.svelte +++ b/site/content/examples/07-stores/01-auto-subscriptions/Resetter.svelte @@ -1,8 +1,8 @@ diff --git a/site/content/examples/07-stores/01-auto-subscriptions/stores.js b/site/content/examples/07-stores/01-auto-subscriptions/stores.js index cdd10e573b..143e0c99f0 100644 --- a/site/content/examples/07-stores/01-auto-subscriptions/stores.js +++ b/site/content/examples/07-stores/01-auto-subscriptions/stores.js @@ -1,3 +1,3 @@ import { writable } from 'svelte/store'; -export const counter = writable(0); \ No newline at end of file +export const count = writable(0); \ No newline at end of file diff --git a/site/content/examples/07-stores/04-custom-stores/App.svelte b/site/content/examples/07-stores/04-custom-stores/App.svelte index c976849a10..a320cc052f 100644 --- a/site/content/examples/07-stores/04-custom-stores/App.svelte +++ b/site/content/examples/07-stores/04-custom-stores/App.svelte @@ -1,9 +1,9 @@ -

The counter is {$counter}

+

The count is {$count}

- - - \ No newline at end of file + + + \ No newline at end of file diff --git a/site/content/examples/07-stores/04-custom-stores/stores.js b/site/content/examples/07-stores/04-custom-stores/stores.js index eec03432c4..5a26025b03 100644 --- a/site/content/examples/07-stores/04-custom-stores/stores.js +++ b/site/content/examples/07-stores/04-custom-stores/stores.js @@ -1,6 +1,6 @@ import { writable } from 'svelte/store'; -function createCounter() { +function createCount() { const { subscribe, set, update } = writable(0); return { @@ -11,4 +11,4 @@ function createCounter() { }; } -export const counter = createCounter(); \ No newline at end of file +export const count = createCount(); \ No newline at end of file diff --git a/site/content/tutorial/08-stores/01-writable-stores/app-a/App.svelte b/site/content/tutorial/08-stores/01-writable-stores/app-a/App.svelte index 802ccc5da3..c26bdfe22d 100644 --- a/site/content/tutorial/08-stores/01-writable-stores/app-a/App.svelte +++ b/site/content/tutorial/08-stores/01-writable-stores/app-a/App.svelte @@ -1,17 +1,17 @@ -

The counter is {counterValue}

+

The count is {countValue}

diff --git a/site/content/tutorial/08-stores/01-writable-stores/app-a/Decrementer.svelte b/site/content/tutorial/08-stores/01-writable-stores/app-a/Decrementer.svelte index 3e1041b7ff..9bd4422f49 100644 --- a/site/content/tutorial/08-stores/01-writable-stores/app-a/Decrementer.svelte +++ b/site/content/tutorial/08-stores/01-writable-stores/app-a/Decrementer.svelte @@ -1,5 +1,5 @@ -

The counter is {counterValue}

+

The count is {countValue}

diff --git a/site/content/tutorial/08-stores/01-writable-stores/app-b/Decrementer.svelte b/site/content/tutorial/08-stores/01-writable-stores/app-b/Decrementer.svelte index 2456344c56..043b795047 100644 --- a/site/content/tutorial/08-stores/01-writable-stores/app-b/Decrementer.svelte +++ b/site/content/tutorial/08-stores/01-writable-stores/app-b/Decrementer.svelte @@ -1,8 +1,8 @@ diff --git a/site/content/tutorial/08-stores/01-writable-stores/app-b/Incrementer.svelte b/site/content/tutorial/08-stores/01-writable-stores/app-b/Incrementer.svelte index 8274287742..2b5763012b 100644 --- a/site/content/tutorial/08-stores/01-writable-stores/app-b/Incrementer.svelte +++ b/site/content/tutorial/08-stores/01-writable-stores/app-b/Incrementer.svelte @@ -1,8 +1,8 @@ diff --git a/site/content/tutorial/08-stores/01-writable-stores/app-b/Resetter.svelte b/site/content/tutorial/08-stores/01-writable-stores/app-b/Resetter.svelte index 8882e35d57..4183421e51 100644 --- a/site/content/tutorial/08-stores/01-writable-stores/app-b/Resetter.svelte +++ b/site/content/tutorial/08-stores/01-writable-stores/app-b/Resetter.svelte @@ -1,8 +1,8 @@ diff --git a/site/content/tutorial/08-stores/01-writable-stores/app-b/stores.js b/site/content/tutorial/08-stores/01-writable-stores/app-b/stores.js index cdd10e573b..143e0c99f0 100644 --- a/site/content/tutorial/08-stores/01-writable-stores/app-b/stores.js +++ b/site/content/tutorial/08-stores/01-writable-stores/app-b/stores.js @@ -1,3 +1,3 @@ import { writable } from 'svelte/store'; -export const counter = writable(0); \ No newline at end of file +export const count = writable(0); \ No newline at end of file diff --git a/site/content/tutorial/08-stores/01-writable-stores/text.md b/site/content/tutorial/08-stores/01-writable-stores/text.md index a6f3669100..dc7081f46a 100644 --- a/site/content/tutorial/08-stores/01-writable-stores/text.md +++ b/site/content/tutorial/08-stores/01-writable-stores/text.md @@ -4,15 +4,15 @@ title: Writable stores Not all application state belongs inside your application's component hierarchy. Sometimes, you'll have values that need to be accessed by multiple unrelated components, or by a regular JavaScript module. -In Svelte, we do this with *stores*. A store is simply an object with a `subscribe` method that allows interested parties to be notified whenever the store value changes. In `App.svelte`, `counter` is a store, and we're setting `counterValue` in the `counter.subscribe` callback. +In Svelte, we do this with *stores*. A store is simply an object with a `subscribe` method that allows interested parties to be notified whenever the store value changes. In `App.svelte`, `count` is a store, and we're setting `countValue` in the `count.subscribe` callback. -Click the `stores.js` tab to see the definition of `counter`. It's a *writable* store, which means it has `set` and `update` methods in addition to `subscribe`. +Click the `stores.js` tab to see the definition of `count`. It's a *writable* store, which means it has `set` and `update` methods in addition to `subscribe`. Now go to the `Incrementer.svelte` tab so that we can wire up the `+` button: ```js function increment() { - counter.update(n => n + 1); + count.update(n => n + 1); } ``` @@ -22,6 +22,6 @@ Finally, in `Resetter.svelte`, implement `reset`: ```js function reset() { - counter.set(0); + count.set(0); } ``` diff --git a/site/content/tutorial/08-stores/02-auto-subscriptions/app-a/App.svelte b/site/content/tutorial/08-stores/02-auto-subscriptions/app-a/App.svelte index 802ccc5da3..481b3070dc 100644 --- a/site/content/tutorial/08-stores/02-auto-subscriptions/app-a/App.svelte +++ b/site/content/tutorial/08-stores/02-auto-subscriptions/app-a/App.svelte @@ -1,17 +1,17 @@ -

The counter is {counterValue}

+

The count is {countValue}

diff --git a/site/content/tutorial/08-stores/02-auto-subscriptions/app-a/Decrementer.svelte b/site/content/tutorial/08-stores/02-auto-subscriptions/app-a/Decrementer.svelte index 2456344c56..043b795047 100644 --- a/site/content/tutorial/08-stores/02-auto-subscriptions/app-a/Decrementer.svelte +++ b/site/content/tutorial/08-stores/02-auto-subscriptions/app-a/Decrementer.svelte @@ -1,8 +1,8 @@ diff --git a/site/content/tutorial/08-stores/02-auto-subscriptions/app-a/Incrementer.svelte b/site/content/tutorial/08-stores/02-auto-subscriptions/app-a/Incrementer.svelte index 8274287742..2b5763012b 100644 --- a/site/content/tutorial/08-stores/02-auto-subscriptions/app-a/Incrementer.svelte +++ b/site/content/tutorial/08-stores/02-auto-subscriptions/app-a/Incrementer.svelte @@ -1,8 +1,8 @@ diff --git a/site/content/tutorial/08-stores/02-auto-subscriptions/app-a/Resetter.svelte b/site/content/tutorial/08-stores/02-auto-subscriptions/app-a/Resetter.svelte index 8882e35d57..4183421e51 100644 --- a/site/content/tutorial/08-stores/02-auto-subscriptions/app-a/Resetter.svelte +++ b/site/content/tutorial/08-stores/02-auto-subscriptions/app-a/Resetter.svelte @@ -1,8 +1,8 @@ diff --git a/site/content/tutorial/08-stores/02-auto-subscriptions/app-a/stores.js b/site/content/tutorial/08-stores/02-auto-subscriptions/app-a/stores.js index cdd10e573b..143e0c99f0 100644 --- a/site/content/tutorial/08-stores/02-auto-subscriptions/app-a/stores.js +++ b/site/content/tutorial/08-stores/02-auto-subscriptions/app-a/stores.js @@ -1,3 +1,3 @@ import { writable } from 'svelte/store'; -export const counter = writable(0); \ No newline at end of file +export const count = writable(0); \ No newline at end of file diff --git a/site/content/tutorial/08-stores/02-auto-subscriptions/app-b/App.svelte b/site/content/tutorial/08-stores/02-auto-subscriptions/app-b/App.svelte index fe24d27c4e..10ebfb65bb 100644 --- a/site/content/tutorial/08-stores/02-auto-subscriptions/app-b/App.svelte +++ b/site/content/tutorial/08-stores/02-auto-subscriptions/app-b/App.svelte @@ -1,11 +1,11 @@ -

The counter is {$counter}

+

The count is {$count}

diff --git a/site/content/tutorial/08-stores/02-auto-subscriptions/app-b/Decrementer.svelte b/site/content/tutorial/08-stores/02-auto-subscriptions/app-b/Decrementer.svelte index 2456344c56..043b795047 100644 --- a/site/content/tutorial/08-stores/02-auto-subscriptions/app-b/Decrementer.svelte +++ b/site/content/tutorial/08-stores/02-auto-subscriptions/app-b/Decrementer.svelte @@ -1,8 +1,8 @@ diff --git a/site/content/tutorial/08-stores/02-auto-subscriptions/app-b/Incrementer.svelte b/site/content/tutorial/08-stores/02-auto-subscriptions/app-b/Incrementer.svelte index 8274287742..2b5763012b 100644 --- a/site/content/tutorial/08-stores/02-auto-subscriptions/app-b/Incrementer.svelte +++ b/site/content/tutorial/08-stores/02-auto-subscriptions/app-b/Incrementer.svelte @@ -1,8 +1,8 @@ diff --git a/site/content/tutorial/08-stores/02-auto-subscriptions/app-b/Resetter.svelte b/site/content/tutorial/08-stores/02-auto-subscriptions/app-b/Resetter.svelte index 8882e35d57..4183421e51 100644 --- a/site/content/tutorial/08-stores/02-auto-subscriptions/app-b/Resetter.svelte +++ b/site/content/tutorial/08-stores/02-auto-subscriptions/app-b/Resetter.svelte @@ -1,8 +1,8 @@ diff --git a/site/content/tutorial/08-stores/02-auto-subscriptions/app-b/stores.js b/site/content/tutorial/08-stores/02-auto-subscriptions/app-b/stores.js index cdd10e573b..143e0c99f0 100644 --- a/site/content/tutorial/08-stores/02-auto-subscriptions/app-b/stores.js +++ b/site/content/tutorial/08-stores/02-auto-subscriptions/app-b/stores.js @@ -1,3 +1,3 @@ import { writable } from 'svelte/store'; -export const counter = writable(0); \ No newline at end of file +export const count = writable(0); \ No newline at end of file diff --git a/site/content/tutorial/08-stores/02-auto-subscriptions/text.md b/site/content/tutorial/08-stores/02-auto-subscriptions/text.md index 9b133ef66c..2bed4a67d1 100644 --- a/site/content/tutorial/08-stores/02-auto-subscriptions/text.md +++ b/site/content/tutorial/08-stores/02-auto-subscriptions/text.md @@ -7,8 +7,8 @@ The app in the previous example works, but there's a subtle bug — the store is Start by declaring `unsubscribe` in `App.svelte`: ```js -const unsubscribe = counter.subscribe(value => { - counterValue = value; +const unsubscribe = count.subscribe(value => { + countValue = value; }); ``` > Calling a `subscribe` method returns an `unsubscribe` function. @@ -18,38 +18,38 @@ You now declared `unsubscribe`, but it still needs to be called, for example thr ```html -

The counter is {counterValue}

+

The count is {countValue}

``` It starts to get a bit boilerplatey though, especially if your component subscribes to multiple stores. Instead, Svelte has a trick up its sleeve — you can reference a store value by prefixing the store name with `$`: ```html -

The counter is {$counter}

+

The count is {$count}

``` > Auto-subscription only works with store variables that are declared (or imported) at the top-level scope of a component. -You're not limited to using `$counter` inside the markup, either — you can use it anywhere in the ` -

The counter is {$counter}

+

The count is {$count}

- - - \ No newline at end of file + + + \ No newline at end of file diff --git a/site/content/tutorial/08-stores/05-custom-stores/app-a/stores.js b/site/content/tutorial/08-stores/05-custom-stores/app-a/stores.js index 9ba73dd21d..ccb322652b 100644 --- a/site/content/tutorial/08-stores/05-custom-stores/app-a/stores.js +++ b/site/content/tutorial/08-stores/05-custom-stores/app-a/stores.js @@ -1,6 +1,6 @@ import { writable } from 'svelte/store'; -function createCounter() { +function createCount() { const { subscribe, set, update } = writable(0); return { @@ -11,4 +11,4 @@ function createCounter() { }; } -export const counter = createCounter(); \ No newline at end of file +export const count = createCount(); \ No newline at end of file diff --git a/site/content/tutorial/08-stores/05-custom-stores/app-b/App.svelte b/site/content/tutorial/08-stores/05-custom-stores/app-b/App.svelte index c976849a10..a320cc052f 100644 --- a/site/content/tutorial/08-stores/05-custom-stores/app-b/App.svelte +++ b/site/content/tutorial/08-stores/05-custom-stores/app-b/App.svelte @@ -1,9 +1,9 @@ -

The counter is {$counter}

+

The count is {$count}

- - - \ No newline at end of file + + + \ No newline at end of file diff --git a/site/content/tutorial/08-stores/05-custom-stores/app-b/stores.js b/site/content/tutorial/08-stores/05-custom-stores/app-b/stores.js index eec03432c4..5a26025b03 100644 --- a/site/content/tutorial/08-stores/05-custom-stores/app-b/stores.js +++ b/site/content/tutorial/08-stores/05-custom-stores/app-b/stores.js @@ -1,6 +1,6 @@ import { writable } from 'svelte/store'; -function createCounter() { +function createCount() { const { subscribe, set, update } = writable(0); return { @@ -11,4 +11,4 @@ function createCounter() { }; } -export const counter = createCounter(); \ No newline at end of file +export const count = createCount(); \ No newline at end of file diff --git a/site/content/tutorial/08-stores/05-custom-stores/text.md b/site/content/tutorial/08-stores/05-custom-stores/text.md index b41809eb81..febd0ad7f7 100644 --- a/site/content/tutorial/08-stores/05-custom-stores/text.md +++ b/site/content/tutorial/08-stores/05-custom-stores/text.md @@ -4,10 +4,10 @@ title: Custom stores As long as an object correctly implements the `subscribe` method, it's a store. Beyond that, anything goes. It's very easy, therefore, to create custom stores with domain-specific logic. -For example, the `counter` store from our earlier example could include `increment`, `decrement` and `reset` methods and avoid exposing `set` and `update`: +For example, the `count` store from our earlier example could include `increment`, `decrement` and `reset` methods and avoid exposing `set` and `update`: ```js -function createCounter() { +function createCount() { const { subscribe, set, update } = writable(0); return {