Class: Dommy::Js::HostEventListener
- Inherits:
-
Object
- Object
- Dommy::Js::HostEventListener
- Defined in:
- lib/dommy/js/host_bridge.rb
Overview
An event listener backed by a live JS object implementing the
EventListener interface (a handleEvent method, e.g. Stimulus's action
listeners). Implements #handle_event so Dommy's invoke_listener routes to
the object's handleEvent (with this bound to the object). Holds the
JS-side ref so it also wraps back to the same JS object (identity kept).
Instance Attribute Summary collapse
-
#ref ⇒ Object
readonly
Returns the value of attribute ref.
Instance Method Summary collapse
- #handle_event(event) ⇒ Object
-
#initialize(bridge, ref, label = nil) ⇒ HostEventListener
constructor
A new instance of HostEventListener.
Constructor Details
#initialize(bridge, ref, label = nil) ⇒ HostEventListener
Returns a new instance of HostEventListener.
506 507 508 509 510 |
# File 'lib/dommy/js/host_bridge.rb', line 506 def initialize(bridge, ref, label = nil) @bridge = bridge @ref = ref @label = label end |
Instance Attribute Details
#ref ⇒ Object (readonly)
Returns the value of attribute ref.
504 505 506 |
# File 'lib/dommy/js/host_bridge.rb', line 504 def ref @ref end |
Instance Method Details
#handle_event(event) ⇒ Object
512 513 514 |
# File 'lib/dommy/js/host_bridge.rb', line 512 def handle_event(event) @bridge.invoke_js_ref_handle_event(@ref, event) end |