react.rb icon indicating copy to clipboard operation
react.rb copied to clipboard

use event handlers instead of procs for callbacks

Open catmando opened this issue 9 years ago • 3 comments

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.

catmando avatar Dec 22 '15 17:12 catmando

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?

ajjahn avatar Dec 22 '15 19:12 ajjahn

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.

catmando avatar Dec 22 '15 20:12 catmando

This issue was moved to reactrb/reactrb#109

sollycatprint avatar Jun 13 '16 13:06 sollycatprint