Yes good point, I think when I wrote most of my write to storage methods a few years ago I probably just copied them from ones where I was reading from storage where I, of course, need to wait for it to read, I do have a couple where it writes that I do want to wait because I need to be sure the data has been written to local storage before the next action happens to prevent any data loss but on this occasion, as you say there is no need to wait.
Okay I will take a look at that, I wrote this method recently when migrating from Ionic 3 to Ionic 5 based on a recommendation (within a blog post) of using ReplaySubject rather than BehaviourSubject but I cannot remember the reasons they suggested ReplaySubject instead!
That makes sense so I guess it would mean modifying your peekJob example to check if it was undefined and if so return it from local storage? I assume this wouldn’t cause a problem the fact that local storage would be returning a promise that I would need to wait for?
Do you recommend calling these within the “constructor” as opposed to within “ionViewWillEnter”? If so what is the reason for this? Do we know if the “constructor” of a page gets called when the App resumes from the background which I think “ionViewWillEnter” does? My concern is that the peek/poke/watch etc will also get lost when iOS does whatever it is doing that is causing my problem.
I am not using Capacitor but I do have the following within app.component.ts which I assume would do the same thing?
// When App resumes from background
this.platform.resume.subscribe(() => {
// do the stuff
}