Created
February 19, 2020 17:16
-
-
Save blueskyfish/9a6db54a0f67aade295cd7646e280911 to your computer and use it in GitHub Desktop.
Collection of Subscription
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { SubscriptionLike } from 'rxjs'; | |
export class SubscriberList implements SubscriptionLike { | |
private mList: SubscriptionLike[] = []; | |
private mClosed = false; | |
get closed(): boolean { | |
return this.mClosed; | |
} | |
add(s: SubscriptionLike): SubscriptionLike { | |
if (s != null) { | |
this.mList.push(s); | |
} | |
return s; | |
} | |
unsubscribe(): void { | |
this.mClosed = true; | |
this.mList.forEach(s => { | |
if (!s.closed) { | |
s.unsubscribe(); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment