fix deriving from rxjs observables (#4298)

pull/4300/head
Conduitry 6 years ago
parent 018953c81b
commit d81f5690ad

@ -48,8 +48,8 @@ export function validate_store(store, name) {
}
}
export function subscribe(store, callback) {
const unsub = store.subscribe(callback);
export function subscribe(store, ...args) {
const unsub = store.subscribe(...args);
return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;
}

@ -1,4 +1,4 @@
import { run_all, noop, safe_not_equal, is_function, get_store_value } from 'svelte/internal';
import { run_all, subscribe, noop, safe_not_equal, is_function, get_store_value } from 'svelte/internal';
/** Callback to inform of a value updates. */
type Subscriber<T> = (value: T) => void;
@ -173,7 +173,8 @@ export function derived<T>(stores: Stores, fn: Function, initial_value?: T): Rea
}
};
const unsubscribers = stores_array.map((store, i) => store.subscribe(
const unsubscribers = stores_array.map((store, i) => subscribe(
store,
(value) => {
values[i] = value;
pending &= ~(1 << i);

Loading…
Cancel
Save