Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70746

[Ionic 4] Reuse same previously fetched data

$
0
0

@devmob-firb wrote:

Hello, I tried to find in the forum and reading the documentation (on the lifecycle hooks part) but couldn’t find the proper answer.

I have in my page a ion-segment with two options which each one has a its own API call to fetch the data and render the response on each specific segment, like this:

        <ion-segment [(ngModel)]="selectedSegment">
            <ion-segment-button value="last">Last</ion-segment-button>
            <ion-segment-button value="next">Next</ion-segment-button>
        </ion-segment>

        <ion-list [ngSwitch]="selectedSegment">
            <ng-container *ngSwitchCase="'last'">
                <page-A></page-A>
            </ng-container>
            <ng-container *ngSwitchCase="'next'">
                <page-B></page-B>
            </ng-container>
        </ion-list>

I need to cache (or whatever the correct definition) the values when I move out and return to the same segment/page because the API gets called everytime when I navigate back to the page with already fetched (and unchanged) data.

Thanks and sorry in advance if this is a very basic concept that I didn’t grasp it in Ionic.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70746

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>