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
I'm using the atomic update function, but after the update I want to keep the update value. Currently, it returns Promise<void>, and I want it to return Promise<T | undefined>.
My use case is persisting state in a React app. When I update the React state, I also update the data in IDB, and I want to keep IDB and React in sync.
There are two workarounds, and I'm using both:
Keep the data in javascript state (which I'm doing anyway) and then also call the update function on the JS state. This works, but I'm worried that the state could drift apart.
Reload the data from IDB after every update (and overwrite any data in React). This keeps React and IDB in sync, but means I'm making two calls to IDB. It doesn't cause any race conditions for me but it could for other use cases.
I think this feature would be especially useful for people who aren't keeping the data around in their app state, and just want to do something with the data after an update.
It would technically be a breaking change. People probably aren't doing anything with the specific void value that update currently returns, but it could cause typescript builds to fail if the signature changes. One way to mitigate that would be to add a new separate updateAndGet function, and leave update unchanged.
The text was updated successfully, but these errors were encountered:
The get and del aren't atomic, so there's a race condition if someone else writes other data to that key inbetween. I'd like to do the get, check, and delete in a single update:
I'm using the atomic
update
function, but after the update I want to keep the update value. Currently, it returnsPromise<void>
, and I want it to returnPromise<T | undefined>
.My use case is persisting state in a React app. When I update the React state, I also update the data in IDB, and I want to keep IDB and React in sync.
There are two workarounds, and I'm using both:
My workaround (roughly):
I would prefer to do:
I think this feature would be especially useful for people who aren't keeping the data around in their app state, and just want to do something with the data after an update.
It would technically be a breaking change. People probably aren't doing anything with the specific
void
value that update currently returns, but it could cause typescript builds to fail if the signature changes. One way to mitigate that would be to add a new separateupdateAndGet
function, and leaveupdate
unchanged.The text was updated successfully, but these errors were encountered: