Skip to content

Commit 0193422

Browse files
authored
Add store signature
Not sure exactly what the syntax of these signatures are, but they look like TypeScript, so that's what I went with for the object literal too.
1 parent eaa3416 commit 0193422

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

site/content/docs/01-component-format.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,15 @@ Local variables (that do not represent store values) must *not* have a `$` prefi
174174

175175
---
176176

177-
You can create your own stores without relying on [`svelte/store`](docs#svelte_store), by implementing the **store contract**:
177+
##### Store contract
178+
179+
```js
180+
store = { subscribe: (subscription: (value: any) => void) => () => void, set?: (value: any) => void }
181+
```
182+
183+
---
184+
185+
You can create your own stores without relying on [`svelte/store`](docs#svelte_store), by implementing the *store contract*:
178186

179187
1. A store must contain a `.subscribe` method, which must accept as its argument a subscription function. This subscription function must be immediately and synchronously called with the store's current value upon calling `.subscribe`. All of a store's active subscription functions must later be synchronously called whenever the store's value changes.
180188
2. The `.subscribe` method must return an unsubscribe function. Calling an unsubscribe function must stop its subscription, and its corresponding subscription function must not be called again by the store.

0 commit comments

Comments
 (0)