tauri-apps / tauri-apps/plugins-workspace
[plugin-store] Allow Atomic Read-then-Write Updates for Store
- Dominant language
- Rust
- Stars
- 1.8k
- Forks
- 602
- Avg merge
- 4d 14h
- Merged PRs (30d)
- 9
Description
### Describe the problem
I would like to request support for atomic read-then-write (e.g. incrementing a stored value with `store.get()` then `store.set()`) update for store by exposing a way to lock the inner store. It was originally possible with `with_store`, which locks the inner store before executing the closure, but it was removed in #1860
### Describe the solution you'd like
IMO, adding back `with_store` is sufficient for this usage.
### Alternatives considered
I tried to wrap the store with a mutex and store it in the managed app state. It works but this needs to be used with care as `get_store` should no longer be used or else the mutex is completely useless as we can access the store directly without lock.
### Additional context
I tried to search for the reason why it was removed but to no avail, perhaps it was not meant for batched **atomic** operation in the first place so replacing it with `get_store` is reasonable.
PS: If there is another (better) way to do this besides from the above alternative, I'd love to know. Thanks
Contributor guide
Assessment
This issue has not been assessed yet.