An observable of an observable?

Is an observable of an observable possible? I have written a custom provider which has a working firebaselistobservable attached to it to pull data from a firebase database. As expected when the database changes the info in the observables updates.

To show this to users I then have several tabs which are displaying this provider from firebase. In order to show the live contents I decided a second observable would be the way to go. But while I can show the info the first time, when the user filters the data the changes do not get reflected to the user. Before I waste a tonne more time on this…in theory should an observable of a firebaselistobservable work? And should all pages which access the data get automatically updated when the root observable updates?

Sorry if that’s a headache lol. I can supply code if needed (would have done anyway but not on my machine just now)

Cheers

I guess that depends on how you define “work”. I suppose it’s theoretically possible, but I can’t think of a real-world situation in which it would be particularly useful. I would look into transformational operators like map and mergeMap instead.

Thanks rapropos, so in the situation where I have:

Firebase Database < is read by > Ionic Provider < is accessed by > app.js, home.js, vids.js and pics.js

where app.js contains a function to trigger a function in the provider to read/filter the data coming in from the database (triggered by a user event) and update the firebase observable, the use of a map/mergeMap would allow the appropriate data to be refreshed on the tabs? (home, vids and pics)?

It is the refreshing of the data displayed in the tabs based on the new data in the provider which is causing me the major headache.

cheers
M

ahhh on further research a ngrx store might be the easiest option to update all tabs… information overload! lol

Basic Ionic 2 plunk based on the Angular QuickStart plunk showing how to integrate
ngrx4 to hold global state shared between two tabs

1 Like