How to get Ionic page informed about some event from provider?

I am really struggling with this one, right now I am using chart.js in my page, and I download data from my server every 1 minute in a provider class, so I also have to refresh the chart every 1 minute, and I dont know how to get my page informed that the chart should be refreshed at some point in time. Is there any way to do that?

Expose an Observable (some flavor of Subject would probably be most straightforward) in the provider that makes the requests that emits new values every time new data comes in. Subscribe to it in your page and update a page property in your subscription.

I was trying that but because there is an async call in my provider(API request) the chart refresh function is actually getting done before the new data arrives

This doesn’t make sense to me. The new data arriving is what triggers a new emission in the Subject, which triggers a new chart refresh. The chart can’t update too early because the property it’s relying on doesn’t change until the subscription fires.

ok, so how can I implement that?
I think I understand what you are saying but still I have no clue about some keyword that I am supposed to use
this is my data function that got called every minute:

      let startTime = new Date(Math.ceil(new Date().getTime() / 60000) * 60000);
      this.Source = Rx.Observable.timer(startTime, 60000).timeInterval().pluck('interval');

      this.Subscription = this.Source
        .subscribe(data => {

              this.http.post(this.ConnectionString + '/api/MacMyWork/Ping', JSON.stringify({ headers: headers })
                .map(res => res.json())
                .subscribe(data => {
                 //code inside
                  resolve(data);
                }, (err) => {
                  reject(err);
                });
        });

or maybe I will just move observable into the page class and it will trigger the event from provider which will resolve into chart refresh, I think it will be simpler to make

edit: no, this isn’t good idea, nvm

are you still there? :frowning:

Did you manage to solve this problem?

yeah but its not like a problem, just design pattern