# Observable not updating the UI

**URL:** <https://forum.ionicframework.com/t/observable-not-updating-the-ui/101036>\
**Category:** ionic-v3\
**Created:** [August 6, 2017, 3:58pm UTC](https://forum.ionicframework.com/t/observable-not-updating-the-ui/101036 "2017-08-06T15:58:48Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Keyjin](https://avatars.discourse-cdn.com/v4/letter/k/ecae2f/32.png) [@Keyjin](https://forum.ionicframework.com/u/Keyjin)\
**Post date:** [August 6, 2017, 3:58pm UTC](https://forum.ionicframework.com/t/observable-not-updating-the-ui/101036/1 "2017-08-06T15:58:48Z")

</div>

Hello together,

i have the issue that observable doesnt trigger UI refresh. But this behaviur is only if im not use the standard browser(ionic serve).  
Following Examples:

Works with workaround ngzone-run:

https://player.vimeo.com/video/228562425

```auto
export class HomePage extends SubscribeAndGuard
{
  public taskProcessTypeCode: typeof TaskProcessTypeCode = TaskProcessTypeCode;
  public isOnline: boolean;

  constructor(
    public navCtrl: NavController,
    public navParams: NavParams,
    private translateService: TranslateService,
    private _store: Store<States>,
    private appActions: AppActions,
    private ngZone: NgZone
  )
  {
    super();
    this._store.select(state => state.appState.isOnline).subscribe(online => this.ngZone.run(() => this.isOnline = online));
  }

```

HTML

```auto
<ion-title text-center>{{ 'HOME' | translate }} {{(isOnline)}}</ion-title>

```

Works not:

https://player.vimeo.com/video/228563082

```auto
export class HomePage extends SubscribeAndGuard
{
  public taskProcessTypeCode: typeof TaskProcessTypeCode = TaskProcessTypeCode;
  public isOnline: Observable<boolean>;

  constructor(
    public navCtrl: NavController,
    public navParams: NavParams,
    private translateService: TranslateService,
    private _store: Store<States>,
    private appActions: AppActions
  )
  {
    super();
    this.isOnline = this._store.select(state => state.appState.isOnline);
  }

```

HTML

```auto
<ion-title text-center>{{ 'HOME' | translate }} {{(isOnline | async)}}</ion-title>

```

Do i anything wrong here?

Thanks and Kind Regards,  
Keyjin

---

<div class="post-metadata">

**Author:** ![AaronSterling](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@AaronSterling](https://forum.ionicframework.com/u/AaronSterling)\
**Post date:** [August 6, 2017, 7:20pm UTC](https://forum.ionicframework.com/t/observable-not-updating-the-ui/101036/2 "2017-08-06T19:20:54Z")

</div>

Better to subscribe using the async pipe and a getter.

```auto
get nameOfObservable() { // define your Observable you want to subscribe to in the ts file }

<div>Look at this: {{nameOfObservable | async}}</div>

```

---

<div class="post-metadata">

**Author:** ![Keyjin](https://avatars.discourse-cdn.com/v4/letter/k/ecae2f/32.png) [@Keyjin](https://forum.ionicframework.com/u/Keyjin)\
**Post date:** [August 6, 2017, 7:42pm UTC](https://forum.ionicframework.com/t/observable-not-updating-the-ui/101036/3 "2017-08-06T19:42:37Z")

</div>

Thanks. Did it, but it doesnt work ☹

---

<div class="post-metadata">

**Author:** ![AaronSterling](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@AaronSterling](https://forum.ionicframework.com/u/AaronSterling)\
**Post date:** [August 6, 2017, 7:46pm UTC](https://forum.ionicframework.com/t/observable-not-updating-the-ui/101036/4 "2017-08-06T19:46:31Z")

</div>

Then there’s something going on that you haven’t posted. I’m running ngrx/store and this works fine on real devices.

---

<div class="post-metadata">

**Author:** ![Keyjin](https://avatars.discourse-cdn.com/v4/letter/k/ecae2f/32.png) [@Keyjin](https://forum.ionicframework.com/u/Keyjin)\
**Post date:** [August 6, 2017, 8:14pm UTC](https://forum.ionicframework.com/t/observable-not-updating-the-ui/101036/5 "2017-08-06T20:14:36Z")

</div>

Yeah. Ok… do you have skype or something maybe we can make a call 🙂

---

<div class="post-metadata">

**Author:** ![AaronSterling](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@AaronSterling](https://forum.ionicframework.com/u/AaronSterling)\
**Post date:** [August 6, 2017, 8:23pm UTC](https://forum.ionicframework.com/t/observable-not-updating-the-ui/101036/6 "2017-08-06T20:23:42Z")

</div>

Just follow any official sample project for ngrx if that’s where your Store injector is coming from. Edit to add: I will say, you might be causing yourself problems by using super(). The first thing I would do if I had that problem would be to refactor the code so I didn’t use super() anywhere.

---

<div class="post-metadata">

**Author:** ![Keyjin](https://avatars.discourse-cdn.com/v4/letter/k/ecae2f/32.png) [@Keyjin](https://forum.ionicframework.com/u/Keyjin)\
**Post date:** [August 6, 2017, 8:29pm UTC](https://forum.ionicframework.com/t/observable-not-updating-the-ui/101036/7 "2017-08-06T20:29:48Z")

</div>

but this is not related to ngrx. This is just a ionic native plugin. Super has no effect on that. Already tried it.

```auto
export class HomePage
{
  public taskProcessTypeCode: typeof TaskProcessTypeCode = TaskProcessTypeCode;

  constructor(
    public navCtrl: NavController,
    public navParams: NavParams,
    private translateService: TranslateService,
    private _store: Store<States>,
    private appActions: AppActions
  )
  {
  }

  private syncTasks()
  {
    this._store.dispatch(this.appActions.sync());
  }

  private syncTasksRefresher(refresher)
  {
    this._store.dispatch(this.appActions.sync())
    refresher.complete();
  }

  private countForTaskType(taskProcessTypeCode: TaskProcessTypeCode): Observable<number>
  {
    return this._store.select(state => state.tasks).switchMap((tasks: Task[]) => Observable.from(tasks)
      .count((task: Task) =>
      {
        return task.taskProcessTypeCode == taskProcessTypeCode.toString() && !!task.responsibleUser;
      })
    );
  }

  private isOnline(): Observable<boolean>
  {
    return this._store.select(state => state.appState.isOnline);
  }

  private logout()
  {
    this._store.dispatch(this.appActions.logout());
  }

  private openUserSettings()
  {
    this.navCtrl.push('usersettings');
  }

  private openTaskList(taskProcessTypeCode)
  {
    this.navCtrl.push('tasks', { taskProcessTypeCode: taskProcessTypeCode });
  }
}

```

---

<div class="post-metadata">

**Author:** ![AaronSterling](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@AaronSterling](https://forum.ionicframework.com/u/AaronSterling)\
**Post date:** [August 6, 2017, 8:35pm UTC](https://forum.ionicframework.com/t/observable-not-updating-the-ui/101036/8 "2017-08-06T20:35:50Z")

</div>

It’s hard to believe that you want help if you don’t include the name of the plugin in the title, in your OP, or in any subsequent post. Also, I think it’s likely that you do not understand what effect Angular page inheritance has on your project.

---

<div class="post-metadata">

**Author:** ![Keyjin](https://avatars.discourse-cdn.com/v4/letter/k/ecae2f/32.png) [@Keyjin](https://forum.ionicframework.com/u/Keyjin)\
**Post date:** [August 7, 2017, 10:07am UTC](https://forum.ionicframework.com/t/observable-not-updating-the-ui/101036/9 "2017-08-07T10:07:54Z")

</div>

im sry. No im relative new to ionic. Can you say me please what you need? I also tried it with following Code but same result in platform browser & android

```auto
export class HomePage
{
  public taskProcessTypeCode: typeof TaskProcessTypeCode = TaskProcessTypeCode;

  public online: boolean = false;

  constructor(
    public navCtrl: NavController,
    public navParams: NavParams,
    private translateService: TranslateService,
    private _store: Store<States>,
    private appActions: AppActions,
    private network: Network
  )
  {
    this.network.onConnect().subscribe(() => { this.online = true; console.log('online') });
    this.network.onDisconnect().subscribe(() => { this.online = false; console.log('offline') });
  }

```

HTML:

```auto
export class HomePage
{
  public taskProcessTypeCode: typeof TaskProcessTypeCode = TaskProcessTypeCode;

  public online: boolean = false;

  constructor(
    public navCtrl: NavController,
    public navParams: NavParams,
    private translateService: TranslateService,
    private _store: Store<States>,
    private appActions: AppActions,
    private network: Network
  )
  {
    this.network.onConnect().subscribe(() => { this.online = true; console.log('online') });
    this.network.onDisconnect().subscribe(() => { this.online = false; console.log('offline') });
  }

```

So now there is no ngrx store etc between.  
Logs in console get written as expected.

Thanks and Kind Regards,  
Christoph

---

<div class="post-metadata">

**Author:** ![AaronSterling](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@AaronSterling](https://forum.ionicframework.com/u/AaronSterling)\
**Post date:** [August 7, 2017, 12:51pm UTC](https://forum.ionicframework.com/t/observable-not-updating-the-ui/101036/10 "2017-08-07T12:51:04Z")

</div>

Does the word “get” appear in any of the code you’ve tried?

---

<div class="post-metadata">

**Author:** ![Keyjin](https://avatars.discourse-cdn.com/v4/letter/k/ecae2f/32.png) [@Keyjin](https://forum.ionicframework.com/u/Keyjin)\
**Post date:** [August 7, 2017, 1:11pm UTC](https://forum.ionicframework.com/t/observable-not-updating-the-ui/101036/11 "2017-08-07T13:11:24Z")

</div>

thanks for your response. Yes

```auto
  get isOnline(): Observable<boolean>
  {
    return this._store.select(state => state.appState.isOnline);
  }

```

```auto
<ion-title text-center>{{ 'HOME' | translate }} {{(isOnline | async)}}</ion-title>

```

EDIT: As in OP mentioned in ionic serve everything works as expected but on platform android/browser not
