Skip to content

Commit

Permalink
Unify event handler support.
Browse files Browse the repository at this point in the history
  • Loading branch information
janbiedermann committed Oct 17, 2019
1 parent de927da commit e5ae62b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
21 changes: 0 additions & 21 deletions ruby/lib/lucid_component/event_handler.rb

This file was deleted.

4 changes: 3 additions & 1 deletion ruby/lib/react/component/event_handler.rb
Expand Up @@ -8,14 +8,16 @@ def event_handlers
def event_handler(name, &block)
event_handlers << name
%x{
self.react_component.prototype[name] = function(event, info) {
var fun = function(event, info) {
if (typeof event === "object") {
#{ruby_event = ::React::SyntheticEvent.new(`event`)};
} else {
#{ruby_event = `event`};
}
#{`this.__ruby_instance`.instance_exec(ruby_event, `info`, &block)};
}
if (self.lucid_react_component) { self.lucid_react_component.prototype[name] = fun; }
else { self.react_component.prototype[name] = fun; }
}
end
end
Expand Down

0 comments on commit e5ae62b

Please sign in to comment.