Describe the bug
The derived implementation doesn't handle RxJS Observables like other autosubscription stuff does.
Logs
TypeError: "fn is not a function"
To Reproduce
<script>
import { of } from 'rxjs';
import { derived } from 'svelte/store';
const store1 = of('foo');
const store2 = derived(store1, _ => _);
store2.subscribe()();
</script>
Expected behavior
Subscribing to and unsubscribing from a store derived from an observable should work. In particular, this means the 'look to see whether there's an unsubscribe method to call instead' logic we use elsewhere should also be use in the derived implementation.
Information about your Svelte project:
Severity
Probably worth the bytes it would take to fix.
Additional context
A question came up in chat about using Observables in Svelte. I don't know whether the gap this issue describes is part of what was wrong, but the question did lead me to look into this.
We're already shipping a few extra bytes to everyone for RxJS support whether they're using it or not. It would be nice to be able to use the same helper in derived as we're already using in every Svelte project that uses autosubscription, but that might not be possible because of the two-argument subscribe() calls for diamond dependency stuff.
Describe the bug
The
derivedimplementation doesn't handle RxJS Observables like other autosubscription stuff does.Logs
To Reproduce
Expected behavior
Subscribing to and unsubscribing from a store derived from an observable should work. In particular, this means the 'look to see whether there's an
unsubscribemethod to call instead' logic we use elsewhere should also be use in thederivedimplementation.Information about your Svelte project:
Severity
Probably worth the bytes it would take to fix.
Additional context
A question came up in chat about using Observables in Svelte. I don't know whether the gap this issue describes is part of what was wrong, but the question did lead me to look into this.
We're already shipping a few extra bytes to everyone for RxJS support whether they're using it or not. It would be nice to be able to use the same helper in
derivedas we're already using in every Svelte project that uses autosubscription, but that might not be possible because of the two-argumentsubscribe()calls for diamond dependency stuff.