Class: Dommy::Js::HostCallback
- Inherits:
-
Object
- Object
- Dommy::Js::HostCallback
- Defined in:
- lib/dommy/js/host_bridge.rb
Overview
An event listener backed by a live JS function. Implements only the bridge ABI (js_call) — not #call/#handle_event — so Dommy’s invoke_listener routes through the js_call(“call”, [event]) branch.
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #__js_call__(method, args) ⇒ Object
-
#__js_call_with_this__(args, this_arg) ⇒ Object
Invoke with an explicit ‘this` receiver — e.g.
-
#initialize(bridge, id) ⇒ HostCallback
constructor
A new instance of HostCallback.
Constructor Details
#initialize(bridge, id) ⇒ HostCallback
Returns a new instance of HostCallback.
381 382 383 384 |
# File 'lib/dommy/js/host_bridge.rb', line 381 def initialize(bridge, id) @bridge = bridge @id = id end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
379 380 381 |
# File 'lib/dommy/js/host_bridge.rb', line 379 def id @id end |
Instance Method Details
#__js_call__(method, args) ⇒ Object
386 387 388 389 390 |
# File 'lib/dommy/js/host_bridge.rb', line 386 def __js_call__(method, args) return nil unless method == "call" @bridge.invoke_callback(@id, args) end |
#__js_call_with_this__(args, this_arg) ⇒ Object
Invoke with an explicit ‘this` receiver — e.g. a MutationObserver callback whose `this` must be the observer, or an event listener whose `this` is the currentTarget.
395 396 397 |
# File 'lib/dommy/js/host_bridge.rb', line 395 def __js_call_with_this__(args, this_arg) @bridge.invoke_callback(@id, args, this_arg) end |