Ok I am at the end of my rope I admit it! I have looked at this for days and have made no progress. As I have alluded to in a few posts I am writing an app which allows the user to click a button to load in data from Firebase (which works fine) and then the appropriate information is then displayed over 3 tabs. This all works ok…until I change the data from the database. As it stands the new data is downloaded but never refreshed in the tabs - unless I click my refresh button which then loads the data. I have tried so many iterations of current implementation/map/subscribe etc… and now I am at a loss. Any help would be very much appreciated. (much of the code below is stubs and the full implementation has been removed to isolate the firebase refresh UI issue. I have also only included the home tab…as if I can refresh on 1 then I can refresh on all). I know I could use ionViewWillEnter, but if they are already on that tab then loading a new data set should automatically update that tab.
<ion-content padding>
<ion-card>
<ion-card-content>
<h2>Welcome to XXXXXX</h2>
<h3>Using the facilities</h3>
<p>
This starter project comes with simple tabs-based layout for apps
that are going to primarily use a Tabbed UI.
</p>
<p>
Take a look at the <code>src/pages/</code> directory to add or change tabs,
update any existing page or create new pages.
</p>
</ion-card-content>
</ion-card>
<ion-list>
<ion-item class="text" *ngFor="let item of items | async">
{{item | json }}
</ion-item>
</ion-list>
<button ion-button (click)="refreshMe()" >refresh</button>
</ion-content>
Sweet lord I have finally fixed it! this is why I love to hate coding…the depths of despair to the heights of joy in the space of a few mins!
set a timeout in global-vars.ts and used a subscribe in home.ts. Its a little slower than before but works! happy to supply code if it is useful for anyone.
In the constructor of your page: this.relicsStream = this.providerName.relicDataStream();
You might need to tweak this depending on your device, because Angular doesn’t behave the same on all devices. But the basic thing you’re doing wrong is that you’re using your provider like a Java getter, instead of like a reactive stream. Note that I’ve set things up so your items variable is a stream. The async pipe subscribes to (and unsubscribes from) streams.
Cheers Aaron - can you tell I am historically a Java coder then lol
yeah the names are terrible at the moment, the classes have changed so many times that the naming convention was the last thing on my mind lol. However, just spent the last 15 mins updating them to appropriate names
good shout on the device specifics. Will look into this. I am still fairly new to Ionic but more so to this side of it!
I don’t always do this next “rule” but usually: I put the word “Stream” into the name of Observables somewhere, and put the word “Snapshot” into the name of Observable.take(1). Separates them out from more traditional variables.
Supplied parameters do not match any signature of call target.
private _relicDataStream: FirebaseListObservable<any> = new FirebaseListObservable<any>();
Using raw types like that is a pennywise pound foolish fix. Maybe it compiles today, but if you don’t type your stream, you’re asking for bug city if you want to expand past two pages.
Im all confused now. This is my current code: It updates the current tab fine but any preloaded (ie previously visited tabs) wont update unless I add the ionViewDidEnter.
audio.ts is the same. This solution does work (most of the time) but it seems so inelegant! I would have thought that once subscribed and with a timeout all pages which have been previously visited (and hence in memory) would have kept an active listener to the observable? Am I missing something obvious or am I tied to updating via ionViewDidEnter?
btw, I very much appreciate all of your help here!
M