You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a situation where we want to clear a bunch of items from storage, and then set items immediately after. We need to await the clear step before saving to prevent the clear from clearing the newly added items.
We are using forEach to iterate through storage, check each item and remove it if need be. Since remove is async we are awaiting it in the iteratorCallback and our iteratorCallback is marked as async. From the source code for storage we can see that the iteratorCallback is not awaited. This means that the forEach Promise could resolve before all the removes have completed.
Here is a sample of what our clear function is doing:
We have a situation where we want to clear a bunch of items from storage, and then set items immediately after. We need to await the clear step before saving to prevent the clear from clearing the newly added items.
We are using
forEach
to iterate through storage, check each item andremove
it if need be. Sinceremove
is async we are awaiting it in theiteratorCallback
and ouriteratorCallback
is marked as async. From the source code for storage we can see that the iteratorCallback is not awaited. This means that theforEach
Promise could resolve before all theremove
s have completed.Here is a sample of what our
clear
function is doing:We are using
"@ionic/storage": "2.1.3"
The text was updated successfully, but these errors were encountered: