title: Rx Observable not updating when other component causes its data to update and call next
body: <p>In my Angular2 app I have an rx Observable which is exposed to a view. This observable is created in a store and passed to the component via subject.asObservable</p>
  
  <p>I am having a problem getting the page's reference to register next() being called on the Subject if an operation on a sub-page initiates that action, but it works perfectly if its the same page which calls the store.</p>
  
  <p>Below shows the layout and flow of this item, and below that I illustrate in what case it fails.</p>
  
  <blockquote>
    <p>base.store, which houses the subjects next() call</p>
  </blockquote>
  
  <pre><code>  options: { collection: string };
    _subject$: Subject&lt;Array&lt;any&gt;&gt;;
    protected dataStore: {};
  
    constructor(protected http: Http) { }
    init(options) {
      this.options = options;
      this.dataStore = {};
      this.dataStore[options.collection] = [];
      this._subject$ = &lt;Subject&lt;Array&lt;any&gt;&gt;&gt;new Subject();
      this.load();
    }
  
    load() {
      this.http.get(endpointurl).map(response =&gt; response.json()).subscribe(
        data =&gt; {
          this.dataStore[this.options.collection] = data;
          this._subject$.next(this.dataStore[this.options.collection]);
        }),
        err =&gt; console.log("Error load", err));
    }
  
    addEntity(entity: any) {
      this.http.post(endpointurl, entity).subscribe(
        data =&gt; this.load(),
        err =&gt; console.log("Error addEntity", err));
    }
  </code></pre>
  
  <blockquote>
    <p>contacts.store, which exposes the subject asObservable</p>
  </blockquote>
  
  <pre><code>export class ContactStore extends BaseStore {
  
    protected _subject$: Subject&lt;Array&lt;Contact&gt;&gt;;
    options;
  
    constructor(protected http: Http) {
      super(http);
  
      this.options = { collection: "contacts" };
      this.init(this.options);
    }
  
    get contacts$() {
      return this._subject$.asObservable();
    }
  
    addOrUpdateContact(contact: Contact) {
      if(contact._id) this.updateEntity(contact);
      else this.addEntity(contact);
    }
  </code></pre>
  
  <blockquote>
    <p>contacts.component, which consumes the observable and displays the list</p>
  </blockquote>
  
  <pre><code>  public contacts$: Observable&lt;Array&lt;Contact&gt;&gt;;
  
    constructor(private contactsStore: ContactStore) {
      this.contacts$ = this.contactsStore.contacts$;
    }    
  </code></pre>
  
  <blockquote>
    <p>contacts.view, displays the contact</p>
  </blockquote>
  
  <pre><code>&lt;ion-item *ngFor="let contact of contacts$ | async"&gt;{{contact.name}}&lt;/ion-item&gt;
  </code></pre>
  
  <p>Now to illustrate the problem, I use the following line of code to add a new Contact; <code>this.contactsStore.addOrUpdateContact(contact);</code></p>
  
  <ul>
  <li>If I add a contact while contact.view is active, the view updates immediately and everything works great</li>
  <li>If I add a contact on a sub-page (ex; contact.detail), when I return to the parent view the contact page doesn't reflect the newly added contact</li>
  <li>If once I'm back, I then add another Contact from that parent page, the view updates and shows both the new contacts!</li>
  <li>If I navigate away and return to the contacts view it also will show the new contact</li>
  </ul>
  
  <p>I attached a subscribe event to this item everywhere in an attempt to debug. My findings seem to highlight the issue.</p>
  
  <p>The subscribe from within contact.store always catches the add and emits and update. The subscribe from within contact.component does this if it's the active page, but not if the add action happens while I'm in a different component.</p>
  
  <p>How can I ensure that it does, or that it refreshes itself once I return to the page?</p>
  
  <p>Since it seems the issue is caused by the subscribe event not happening in the contacts.component I tried manually triggering updates with ngZone and applicationRef.tick, neither solved the issue.</p>
  
  <p>To help debug I also emit an event "contacts.loaded" immediately following subject.next(). I subscribe to that event on contacts.component. It always fires even in the case when the view doesn't update. I tried putting in ChangeDetectorRef.detectChanges() to no avail.</p>