Skip to content

Commit 14154fc

Browse files
authored
site: document Observable interop (#2571)
1 parent 252ec8c commit 14154fc

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ You can create your own stores without relying on [`svelte/store`](docs#svelte_s
184184
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.
185185
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*.
186186

187+
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.
188+
187189

188190
### <script context="module">
189191

0 commit comments

Comments
 (0)