-
Notifications
You must be signed in to change notification settings - Fork 175
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
Improve WebStorage API #19743
Comments
Agreed that The one gotcha is that directly blocking on that instance (i.e. using |
@Legioth ok, so favouring this instead of the other suggested approaches? Should I create a PR, or are you guys doing it? |
Nobody on our side is looking into this right now so feel free to create a PR if you're interested! |
And yes, preferring to just introduce overloads without a callback and instead returning a |
Adds CompletableFuture methods for WebStorage.getItem. Fixes #19743
This ticket/PR has been released with Vaadin 24.5.0. |
Describe your motivation
I'm programming in kotlin and heavily using coroutines. The WebStorage API only defines static functions with callbacks, which can only be extended as suspending in Kotlin with:
Because these are static methods I couldn't do:
Describe the solution you'd like
That's why I suggest to add overload methods that return a CompletableFuture instead of taking a callback. This way I can easily await on the CompletableFuture. Like:
This way also other reactive frameworks would benefit from it.
The API could be expanded like this without breaking the existing one.
Describe alternatives you've considered
Also I would suggest to refactor the API to use objects. So that the calls could be:
For spsecific UI:
Or as alternative construct it directly as object:
All my suggestions would allow to keep the current static approach without breaking.
The text was updated successfully, but these errors were encountered: