site: document Observable interop (#2571)

pull/4229/head
Conduitry 5 years ago committed by GitHub
parent 252ec8ceca
commit 14154fce36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -184,6 +184,8 @@ You can create your own stores without relying on [`svelte/store`](docs#svelte_s
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.
3. A store may *optionally* contain a `.set` method, which must accept as its argument a new value for the store, and which synchronously calls all of the store's active subscription functions. Such a store is called a *writable store*.
For interoperability with RxJS Observables, the `.subscribe` method is also allowed to return an object with an `.unsubscribe` method, rather than return the unsubscription function directly. Note however that unless `.subscribe` synchronously calls the subscription (which is not required by the Observable spec), Svelte will see the value of the store as `undefined` until it does.
### <script context="module">

Loading…
Cancel
Save