Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Acess to value on watch callback when available #341

Open
1 task done
dvlden opened this issue Nov 16, 2023 · 1 comment
Open
1 task done

Acess to value on watch callback when available #341

dvlden opened this issue Nov 16, 2023 · 1 comment
Labels
discussion enhancement New feature or request

Comments

@dvlden
Copy link

dvlden commented Nov 16, 2023

Describe the feature

I find it weird that watch method doesn't actually provide me k:v pair for example.
Is there any specific reasoning why watcher strictly returns only event and key and can't be customized further?

Building a browser storage driver is not quite good this way. I'd expect in watcher to receive a key and value on update and only key on delete, for example.

With current implementation, I'd need to get the value from the storage, using the key it provides me with, which seem like overhead?

Additional information

  • Would you be willing to help implement this feature?
@pi0 pi0 changed the title Make watch callback more flexible? Acess to value on watch callback when available May 1, 2024
@pi0 pi0 added enhancement New feature or request discussion labels May 1, 2024
@pwFoo
Copy link

pwFoo commented Dec 31, 2024

Hello,
played arround with unstorage and it should take over and replace some of my features code parts out of the box!
Thanks for that awesome project 🥇 👍

watch could much more powerful with callback arguments changed to (key, value, oldValue, event) => {}.

  1. value: Because value should be available during save data and trigger event a get overhead can be avoided?
  2. oldValue: Would be cool for some use cases and helps to have more precise event type (added, updated or deleted) and more flexibility?
  3. event filtering: Ok, just optional if easy to implement because it could be done by a wrapper arround the watch callback... filtering events by key match or regexp / wildcard based filter functions to listen to specific changes

I would love to see value and oldValue for my needs :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants