Port constructor

Port({
  1. required String name,
  2. required JSFunction disconnect,
  3. required JSFunction postMessage,
  4. MessageSender? sender,
})

Implementation

Port({
  /// The name of the port, as specified in the call to [runtime.connect].
  required String name,

  /// Immediately disconnect the port. Calling `disconnect()` on an
  /// already-disconnected port has no effect. When a port is disconnected, no
  /// new events will be dispatched to this port.
  required JSFunction disconnect,

  /// Send a message to the other end of the port. If the port is
  /// disconnected, an error is thrown.
  required JSFunction postMessage,

  /// This property will **only** be present on ports passed to
  /// $(ref:runtime.onConnect onConnect) / $(ref:runtime.onConnectExternal
  /// onConnectExternal) / $(ref:runtime.onConnectExternal onConnectNative)
  /// listeners.
  MessageSender? sender,
}) : _wrapped = $js.Port(
        name: name,
        disconnect: disconnect,
        postMessage: postMessage,
        sender: sender?.toJS,
      );