Class: Dommy::MessageChannel
- Inherits:
-
Object
- Object
- Dommy::MessageChannel
- Defined in:
- lib/dommy/message_channel.rb
Overview
MessageChannel — creates a pair of MessagePorts connected to
each other. port1.postMessage(x) queues a TASK (the "post message" task
source, not a microtask) that fires a message event on port2, and vice
versa — so the message is delivered in a later event-loop turn, after the
current task's microtask checkpoint. React's scheduler relies on this to
yield as a macrotask.
Spec: https://html.spec.whatwg.org/multipage/web-messaging.html
Instance Attribute Summary collapse
-
#port1 ⇒ Object
readonly
Returns the value of attribute port1.
-
#port2 ⇒ Object
readonly
Returns the value of attribute port2.
Instance Method Summary collapse
- #__js_get__(key) ⇒ Object
-
#initialize(window) ⇒ MessageChannel
constructor
A new instance of MessageChannel.
Constructor Details
#initialize(window) ⇒ MessageChannel
Returns a new instance of MessageChannel.
15 16 17 18 19 20 |
# File 'lib/dommy/message_channel.rb', line 15 def initialize(window) @port1 = MessagePort.new(window) @port2 = MessagePort.new(window) @port1.__internal_entangle__(@port2) @port2.__internal_entangle__(@port1) end |
Instance Attribute Details
#port1 ⇒ Object (readonly)
Returns the value of attribute port1.
13 14 15 |
# File 'lib/dommy/message_channel.rb', line 13 def port1 @port1 end |
#port2 ⇒ Object (readonly)
Returns the value of attribute port2.
13 14 15 |
# File 'lib/dommy/message_channel.rb', line 13 def port2 @port2 end |