Sha256: e5f6832a85fe3dc9b836ef551d269368e1aad61d9ce1caf94f3b8c5fb90fc41a

Contents?: true

Size: 713 Bytes

Versions: 9

Compression:

Stored size: 713 Bytes

Contents

module React
  module Component
    module EventHandler
      def event_handlers
        @event_handlers ||= []
      end

      def event_handler(name, &block)
        event_handlers << name
        %x{
          var fun = function(event, info) {
            let ruby_event;
            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
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
isomorfeus-react-16.12.11 lib/react/component/event_handler.rb
isomorfeus-react-16.12.10 lib/react/component/event_handler.rb
isomorfeus-react-16.12.9 lib/react/component/event_handler.rb
isomorfeus-react-16.12.8 lib/react/component/event_handler.rb
isomorfeus-react-16.12.7 lib/react/component/event_handler.rb
isomorfeus-react-16.12.6 lib/react/component/event_handler.rb
isomorfeus-react-16.12.5 lib/react/component/event_handler.rb
isomorfeus-react-16.12.4 lib/react/component/event_handler.rb
isomorfeus-react-16.12.3 lib/react/component/event_handler.rb