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
permalink #event ⇒ Class (readonly)
Returns the class for the event.
98 99 100 |
# File 'opal/browser/event/base.rb', line 98 def event Event.class_for(@name) end |
permalink #name ⇒ Object (readonly)
Returns the value of attribute name.
60 61 62 |
# File 'opal/browser/event/base.rb', line 60 def name @name end |
Instance Method Details
permalink #call(event) ⇒ Object
Call the callback with the given event.
73 74 75 |
# File 'opal/browser/event/base.rb', line 73 def call(event) to_proc.call(event) end |
permalink #off ⇒ Object
Stop listening for the event linked to the callback.
103 104 105 |
# File 'opal/browser/event/base.rb', line 103 def off target.off(self) end |
permalink #to_proc ⇒ Object
Get the native function linked to the callback.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'opal/browser/event/base.rb', line 78 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 |