You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+15-15
Original file line number
Diff line number
Diff line change
@@ -4,15 +4,15 @@
4
4
5
5
A tiny connector for [Storeon] and [Svelte]. ([Demo])
6
6
7
-
Size is only 185 bytes (minified and gzipped). It uses [Size Limit] to control size.
7
+
Size is only 187 bytes (minified and gzipped). It uses [Size Limit] to control size.
8
8
9
9
Read more about Storeon [article].
10
10
11
11
## Why?
12
12
13
13
[Svelte] is the smallest JS framework, but even so, it contains many built-in features. One of them is a `svelte/store`. But why we need to use a third-party store? `@storeon/svelte` has several advantages compared with the built-in one.
14
14
15
-
-**Size**. 185 bytes instead of 426 bytes (minified and gzipped).
15
+
-**Size**. 187 bytes instead of 426 bytes (minified and gzipped).
16
16
-**Ecosystem**. Many additional [tools] can be combined with a store.
17
17
-**Speed**. It tracks what parts of state were changed and re-renders only components based on the changes.
18
18
@@ -75,29 +75,29 @@ export const store = createStoreon<State, Events>([counter])
75
75
76
76
#### `App.svelte`
77
77
78
-
Provide store to Svelte Context using `setStore` from `@storeon/svelte`
78
+
Provide store to Svelte Context using `provideStoreon` from `@storeon/svelte`
79
79
80
80
```html
81
81
<script>
82
-
import { setStore } from'@storeon/svelte'
82
+
import { provideStoreon } from'@storeon/svelte'
83
83
import { store } from'./store'
84
84
importCounterfrom'./Counter.svelte'
85
85
86
-
setStore(store)
86
+
provideStoreon(store)
87
87
</script>
88
88
89
89
<Counter />
90
90
```
91
91
92
-
Import `getStore` function from our `@storeon/svelte` module and use it for getting state and dispatching new events:
92
+
Import `useStoreon` function from our `@storeon/svelte` module and use it for getting state and dispatching new events:
93
93
94
94
#### `Child.svelte`
95
95
96
96
```html
97
97
<script>
98
-
import { getStore } from'@storeon/svelte';
98
+
import { useStoreon } from'@storeon/svelte';
99
99
100
-
const { count, dispatch } =getStore('count');
100
+
const { count, dispatch } =useStoreon('count');
101
101
102
102
functionincrement() {
103
103
dispatch('inc');
@@ -108,13 +108,13 @@ Import `getStore` function from our `@storeon/svelte` module and use it for gett
108
108
109
109
<buttonon:click={increment}>+</button>
110
110
```
111
-
Using typescript you can pass `State` and `Events` interfaces to `getStore` function to be full type safe
111
+
Using typescript you can pass `State` and `Events` interfaces to `useStoreon` function to be full type safe
0 commit comments