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.
pull/4216/head
trbrc 6 years ago committed by GitHub
parent eaa34164bf
commit 0193422a41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -174,7 +174,15 @@ Local variables (that do not represent store values) must *not* have a `$` prefi
---
You can create your own stores without relying on [`svelte/store`](docs#svelte_store), by implementing the **store contract**:
##### Store contract
```js
store = { subscribe: (subscription: (value: any) => void) => () => void, set?: (value: any) => void }
```
---
You can create your own stores without relying on [`svelte/store`](docs#svelte_store), by implementing the *store contract*:
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.
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.

Loading…
Cancel
Save