Sha256: 2a55fb62b37312668bee83a1ccb1ac941794f21ffde2c6f729af7cd2b19c5a1e

Contents?: true

Size: 546 Bytes

Versions: 16

Compression:

Stored size: 546 Bytes

Contents

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

      def event_handler(name, &block)
        event_handlers << name
        %x{
          var fun = function(event, info) {
            if (typeof event === "object") { #{ruby_event = ::React::SyntheticEvent.new(`event`)}; }
            else { #{ruby_event = `event`}; }
            #{`this`.instance_exec(ruby_event, `info`, &block)};
          }
          self[name] = fun;
        }
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
isomorfeus-react-16.12.11 lib/isomorfeus_react/react/function_component/event_handler.rb
isomorfeus-react-16.12.10 lib/isomorfeus_react/react/function_component/event_handler.rb
isomorfeus-react-16.12.9 lib/isomorfeus_react/react/function_component/event_handler.rb
isomorfeus-react-16.12.8 lib/isomorfeus_react/react/function_component/event_handler.rb
isomorfeus-react-16.12.7 lib/isomorfeus_react/react/function_component/event_handler.rb
isomorfeus-react-16.12.6 lib/isomorfeus_react/react/function_component/event_handler.rb
isomorfeus-react-16.12.5 lib/isomorfeus_react/react/function_component/event_handler.rb
isomorfeus-react-16.12.4 lib/react/function_component/event_handler.rb
isomorfeus-react-16.12.3 lib/react/function_component/event_handler.rb
isomorfeus-react-16.12.2 lib/react/function_component/event_handler.rb
isomorfeus-react-16.12.1 lib/react/function_component/event_handler.rb
isomorfeus-react-16.12.0 lib/react/function_component/event_handler.rb
isomorfeus-react-16.11.4 lib/react/function_component/event_handler.rb
isomorfeus-react-16.11.3 lib/react/function_component/event_handler.rb
isomorfeus-react-16.11.2 lib/react/function_component/event_handler.rb
isomorfeus-react-16.11.1 lib/react/function_component/event_handler.rb