Class: Browser::Event::Target::Callback
- Defined in:
- opal/browser/event/base.rb
Instance Attribute Summary collapse
-
#event ⇒ Class
readonly
The class for the event.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#selector ⇒ Object
readonly
Returns the value of attribute selector.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
-
#call(event) ⇒ Object
Call the callback with the given event.
-
#off ⇒ Object
Stop listening for the event linked to the callback.
-
#to_proc ⇒ Object
Get the native function linked to the callback.
Instance Attribute Details
#event ⇒ Class (readonly)
Returns the class for the event.
100 101 102 |
# File 'opal/browser/event/base.rb', line 100 def event Event.class_for(@name) end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
62 63 64 |
# File 'opal/browser/event/base.rb', line 62 def name @name end |
#selector ⇒ Object (readonly)
Returns the value of attribute selector.
62 63 64 |
# File 'opal/browser/event/base.rb', line 62 def selector @selector end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
62 63 64 |
# File 'opal/browser/event/base.rb', line 62 def target @target end |
Instance Method Details
#call(event) ⇒ Object
Call the callback with the given event.
75 76 77 |
# File 'opal/browser/event/base.rb', line 75 def call(event) to_proc.call(event) end |
#off ⇒ Object
Stop listening for the event linked to the callback.
105 106 107 |
# File 'opal/browser/event/base.rb', line 105 def off target.off(self) end |
#to_proc ⇒ Object
Get the native function linked to the callback.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'opal/browser/event/base.rb', line 80 def to_proc @proc ||= -> event { %x{ if (!event.currentTarget) { event.currentTarget = self.target.native; } } event = Event.new(event, self) unless event.stopped? @block.call(event, *event.arguments) end !event.prevented? } end |