react.rb
react.rb copied to clipboard
use event handlers instead of procs for callbacks
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.
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?
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.
This issue was moved to reactrb/reactrb#109