I have a service in Angular 5 which exposes a BehaviorSubject. It needs to 
track a dynamic array of inner subscriptions, that come and go on the fly 
and each, once active, can be "on" or "off" (true/false, whatever). My 
exposed subject should return all values (or, well, just an OR of all 
values, if any is on, my whole service is on). I'm not sure how to do this 
with merge and switchmap and other rx operators. 

Example:

@Injectable() class MyService {
  results$: BehaviorSubject<any> = new BehaviorSubject<any>(false);
  callers: any[] = [];

  getSubject() {
    const subject = new Subject();
    callers.push(subject);
    // TODO: Now what? How to tell result$ to listen to this new one too?
    subject.finally(() = {
      // TODO: Now what? How to kick it out of the array when complete, and 
tell results$?
    });

    return subject;
}


Any pointers on how to achieve this?

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to