-
Notifications
You must be signed in to change notification settings - Fork 17
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
Added withOnSelectedHandlers #81
Conversation
I'm kinda hesitant to pull this PR, for multiple reasons:
|
p.s. To be honest )), I like FP and it was a pleasure for me to build the implementation without introducing new classes, just with help of high-order functions. |
Got it. I'm a fan of FP too; for example I definitely prefer the simplicity of Your One of the problems I see is as follows: say you'll have another function tabs {
withOnSelectedHandlers { onSelected ->
withSomeOtherKindOfHandlers { handler ->
withYetSomethingElse { handler2 ->
tab("Users") {
onSelected {
displayUserList()
}
}
tab("Admins") {
onSelected {
displayAdminList()
}
} Maybe I'm just going ahead too much of myself, but this can happen if this approach is applied to other components as well; and this starts to resemble the callback pyramid of doom too painfully. Also, the state (the The Maybe I would do this a bit differently:
I think this solution is a bit simpler and easier to understand by our fellow programmers. What do you think? |
So do I! I would add that following KISS (e.g. combining the simplest bits OOP and FP) aid even to ourselves to understand what we did when the time has passed.
Wow, that's the great approach! I have not known about |
…ort, Tab.onSelected, Tabs.defaultOnSelectedHandler
withOnSelectedHandlers is a utility that facilitates event handling when a tab is selected.