Module: Fron::Behaviors::Events

Included in:
Component
Defined in:
opal/fron/core/behaviors/events.rb

Overview

Events

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object

Runs for included classes


9
10
11
# File 'opal/fron/core/behaviors/events.rb', line 9

def self.included(base)
  base.register self, [:on]
end

.on(registry) ⇒ Object

Applies events from the registry


16
17
18
19
20
21
22
23
24
# File 'opal/fron/core/behaviors/events.rb', line 16

def self.on(registry)
  registry.each do |args|
    if args.length == 3
      delegate(args[0], args[1]) { |event| send args[2], event }
    else
      on(args[0]) { |event| send args[1], event }
    end
  end
end