Pass data from TabsPage to ChildTab

Hello to all.
I am developing an app that has a 4 tabs
This is the html page


  <ion-tab-bar slot="bottom">

    <ion-tab-button tab="profilo">
      <ion-icon name="person-sharp"></ion-icon>

    <ion-tab-button tab="chat">
      <ion-icon name="chatbubble-sharp"></ion-icon>

    <ion-tab-button tab="random">
      <ion-icon name="search-sharp"></ion-icon>

    <ion-tab-button tab="dintorni">
      <ion-icon name="compass"></ion-icon>


I need to send a request to the server every 5 seconds to get data.
I want to put this call in the main tab (TabsPage) and then pass the data obtained in the TabChat.
Is it possible to do this or do I have to insert the call to the server in each tab?

So the question is this: how do I pass a data from the tabPage to the tabChat?

I choose to put all network activity into services, not pages. If you follow this pattern as well, things become easy. Inject the service whereever it is needed and subscribe to the Observables it exposes to provide streams of data.


YES, I have not specified that I have a service in which I have this function.
So I have to call this service in every tab and then with a notification I warn that there are new messages?

I’m not sure I understand how you’re using “call” there. What I would do is have a service that exposes an Observable<BusinessObject>, and everywhere you need to know when new BusinessObjects arrive, you inject that service, acquire a reference to that Observable and subscribe to it.

Ok, but if i put this service in TabsPage and acquire a reference and then subcribe to it. Then, If I go to the profile tab, does the service in the tabsPage continue to work or do I have to inject it also in the profile tab?

I don’t know how to say anything more useful than “everywhere you need to know when new BusinessObjects arrive”. My main overarching point is that I would like to suggest thinking in a different direction than that implied in your thread title: this should not be about passing data from page to page.

All right. I understand the concept. I’ll do some tests. Thanks :slight_smile: