I'm currently working on an app using Ionic 2 and incorporating the Ionic Native Storage plugin to store key-value pairs. To address potential concurrency problems, I am looking into queuing the storage calls.
For instance, I have functions like saveJob(), getJob() and deleteJob() which all return Promises.
Assuming these methods are being called randomly:
this.storageService.saveJob().then((result) => {
// do something
})
this.storageService.saveJob().then((result) => {
// do something
})
this.storageService.deleteJob().then((result) => {
// do something
})
this.storageService.getJob().then((result) => {
// do something
})
this.storageService.saveJob().then((result) => {
// do something
})
Is there a way for me to queue these requests? I would prefer to manage this within the StorageService provider so that the other parts of my app can seamlessly continue interacting with the StorageService without being aware of the queuing process.