, , "" RxJS 4 ( , ) RxPHP. RxJS 5 , .
Observables. Subscription, , unsubscribe().
var source1 = Observable.interval(250);
var source2 = Observable.interval(350);
let sub1 = source1.subscribe(val => console.log(val));
let sub2 = source2.subscribe(val => console.log(val));
let subscriptions = new Subscription(() => {
sub1.unsubscribe();
sub2.unsubscribe();
});
setTimeout(() => {
subscriptions.unsubscribe();
}, 3000);
, Subscription source1.subscribe Subscription, unsubscribe(), add():
var source1 = Observable.interval(250);
var source2 = Observable.interval(350);
let subscriptions = source1.subscribe(val => console.log(val));
subscriptions.add(source2.subscribe(val => console.log(val)));
setTimeout(() => {
subscriptions.unsubscribe();
}, 3000);
. : https://github.com/ReactiveX/rxjs/blob/master/src/Subscription.ts