Merge branch 'rxjs-support' of https://github.com/benlesh/svelte into benlesh-rxjs-support

pull/2577/head
Richard Harris 5 years ago
commit c4a8e9755f

@ -48,7 +48,12 @@ export function validate_store(store, name) {
}
export function subscribe(component, store, callback) {
component.$$.on_destroy.push(store.subscribe(callback));
let unsub = store.subscribe(callback);
// Prevent memory leaks for RxJS users.
if (unsub.unsubscribe) {
unsub = () => unsub.unsubscribe();
}
component.$$.on_destroy.push(unsub);
}
export function create_slot(definition, ctx, fn) {
@ -74,4 +79,4 @@ export function exclude_internal_props(props) {
const result = {};
for (const k in props) if (k[0] !== '$') result[k] = props[k];
return result;
}
}

Loading…
Cancel
Save