Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49247

Making sure to store my filter settings before returning to main view

$
0
0

@coffeeee wrote:

Hey,

I have a list of items and a filter menu. I need help to ensure that my filter settings are stored before my list of items would load when I return from the filter menu back to my itemlist.

Currently my app looks like this:

In the filter menu I would set my Ionic storage to store the filter settings:

  async ionViewCanLeave() {
     //create filterSettings object
     await this.localDataProv.setFilter(this.filterSettings);
  }

In my list I would build up my list by retrieving the filter settings via .get on my filter storage:

async ionViewWillEnter() {
    this.filterSettings = await this.localDataProv.getFilter();
    //perform filtering of items based on filterSettings
}

My provider is a simple Ionic storage:

  async getFilter() {
    return await this.storage.get('filterCollection');
  }

  async setFilter(data: any) {
    await this.storage.set('filterCollection', data);
    return true;
  }

However, there is no guarantee that my filter storage would set before I retrieve the data within the ionViewWillEnter of my list view.

How can I ensure that the filter will always be set before I return back to my list?

Is there a better approach than this?

Thanks in advance.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49247

Trending Articles



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