RxJS always returns a Subscription object with an unsubscribe.

Co-Authored-By: benlesh <ben@benlesh.com>
pull/2556/head
Rich Harris 5 years ago committed by GitHub
parent e25b7df275
commit 2eba37bdb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -50,7 +50,7 @@ export function validate_store(store, name) {
export function subscribe(component, store, callback) {
let unsub = store.subscribe(callback);
// Prevent memory leaks for RxJS users.
if (typeof unsub === 'object' && typeof unsub.unsubscribe === 'function') {
if (unsub.unsubscribe) {
unsub = () => unsub.unsubscribe();
}
component.$$.on_destroy.push(unsub);

Loading…
Cancel
Save