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

use event handlers instead of procs for callbacks #109

Open
catmando opened this issue Dec 22, 2015 · 3 comments
Open

use event handlers instead of procs for callbacks #109

catmando opened this issue Dec 22, 2015 · 3 comments

Comments

@catmando
Copy link
Collaborator

Instead of passing procs to components for callbacks, use the event mechanism / syntax.

Thus

MyComponent(zee_callback: -> (x) { puts x }...) becomes
MyComponent(...).on(:zee_callback) { .... }

It just looks nicer, and its what you would expect. Its nice consistent semantics - events == callbacks

Inside the component syntax would be the same... i.e. the callback would arrive as a param.

@ajjahn
Copy link
Collaborator

ajjahn commented Dec 22, 2015

My memory is a little fuzzy on this, but isn't something like this on syntax already in place and triggered using the emit method?

@catmando
Copy link
Collaborator Author

hey look at that... it basically uses the implementation I thought was possible, but for whatever reason zetachang first adds "_on" to the front of the method name, then the emit function also adds the "_on" on the front as well. I am sure this harkens to before a lot of the reactive-ruby enhancements were made.

I like my proposal still because it is consistent with all the other changes we have made to the param wrapper.

@sollycatprint
Copy link

This issue was moved to ruby-hyperloop/hyper-react#109

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants