-
Notifications
You must be signed in to change notification settings - Fork 703
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
Button.Clicked is Action and not an event? #101
Comments
Same is true of RadioGroup.SelectionChanged but not TextField.Changed |
Should I create a PR to fix this by converting Action to EventHandler? |
I have just never appreciated EventHandler types. They were invented in an era that lacked lambdas. My problem with it is two fold: the first parameter is rarely used and when you need it lambdas are now available. The second is that the payload to the event rather than being just a value is another type, this is just too much boilerplate in my view. Am I missing something? |
The benefits of events as I see it are:
I'd say the latter three are pretty niche cases, though, at least in the context of a UI library. Personally, I don't have strong feelings either way, other than a bias for consistentcy |
I share Miguel's scorn for events. That said, consistency is a good thing. Sometimes the right answer is to make things consistently awful. If so, events are the perfect way to achieve that. |
I feel they are as noise.
|
Sorry, I meant consistency within the library (TextField.Changed is event vs RadioGroup.SelectionChanged is Action). I agree that events don't bring much to the table here. |
So if for consistency, then pls go for action, there is almost no need for the sender args pattern. :) |
There are other reasons for events instead of actions besides ones mentioned by @pmsanford. |
You can do that yourself without the
|
Sure, it's doable. But is it optimal? Compiler creates a hidden class just for that. |
Good point folks - I am on vacation this week, with limited access to the internet, but will join this conversation next week. There seem to be two issues, one of consistency (public delegate vs event) and whether the signature should be EventHandler or the newer Action/Func pattern. Will ponder here next week. |
Introducing events would be a lie. We do not have concurrent tasks, no UI thread in the background, no devices sending something. When it comes to the terminal, we have an endless loop, polling the keyboard and the mouse - which means essentially waiting for the user - and meanwhile doing things. Regarding the interaction between menu and a statusbar, I'd really appreciate to use Not sure if that somehow interferes with the reactive stuff... |
FWIW, I vote for events. They're standard, a lot of libraries and things are built on top of them. And I'm not sure it's possible to remove an action. Whereas with events I can remove a handler via |
You can remove an action by clearing it: control.Action = null But I hear you, you want events, I need to digest this, I think I will make the change, but it will break people |
Sorry I didn't see this Issue when I created this one: #447 I'm clearly in the I think |
Dupe of #447 |
Why is Button.Clicked (and I assume other events) implemented as Action but not as an event?
I'd say event is more natural and standard.
The text was updated successfully, but these errors were encountered: