@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