Open danielchalmers opened 3 months ago
Thanks for wanting to do a PR, @danielchalmers !
We try to merge all non-breaking bugfixes and will deliberate the value of new features for the community. Please note there is no guarantee your pull request will be merged, so if you want to be sure before investing the work, feel free to contact the team first.
@ScarletKuro @henon @mckaragoz Just an idea I had. Not finished but wonder what you think.
E.g. KeyDown
and KeyUp
could also be callbacks passed through KeyInterceptorFactory.Connect
to allow for async
My idea was to completely rewrite it, make it a scoped service to throw the factory and use ObserverManager
, and the subscribe would have a callback either an Action
or Func
(to support Task and non task callbacks) overload, just like BrowserViewportService
does. The elemendId
is the unique subscription identificator. I have even done it, but just being lazy with the tests.
My idea was to completely rewrite it, make it a scoped service to throw the factory and use
ObserverManager
, and the subscribe would have a callback either anAction
orFunc
(to support Task and non task callbacks) overload, just likeBrowserViewportService
does. TheelemendId
is the unique subscription identificator. I have even done it, but just being lazy with the tests.
@ScarletKuro Please let me know if I can help finish it so I can use it in more components
Crated a draft https://github.com/MudBlazor/MudBlazor/pull/9003
Idk if we want this in v7 or v8, but I just wanted to show how I see the API should be done
Will later think if we can simplify the KeyInterceptorOptions
as @danielchalmers proposed. But main aim was the async / void support.
Idk if we want this in v7 or v8
If it isn't breaking we can do it anytime after v7 has stabilized.
If it isn't breaking we can do it anytime after v7 has stabilized.
I planned to keep the old service aka just mark it as obsolete.
It's better to keep old services for a while until you are completely sure the news ones are mature and has not bugs, just like with the PopoverSerivce
and BrowserViewportService
.
FWIW I want to implement keyboard handling in several controls so I would be glad to use it in v7
Feature request type
Other
Component name
No response
Is your feature request related to a problem?
Thinking about ways to make it simpler to set up the KeyInterceptor. Will use it more with #8901 so am looking at small ways to make it easier to maintain and stay consistent between components with less chance for subtle bugs due to misconfiguration.
Describe the solution you'd like
Usage Before:
Usage After (first draft):
Just the difference in creation (first draft):
Could also
_keyInterceptor.KeyDown += HandleKeyDown;
into a callback parameter._elementId
fromKeyInterceptorFactory.Connect
via a tupleHave you seen this feature anywhere else?
No response
Describe alternatives you've considered
No response
Pull Request
Code of Conduct