Dart Documentationchrome.runtimeOnMessageExternalEvent

OnMessageExternalEvent class

Fired when a message is sent from another extension/app. Cannot be used in a content script.

class OnMessageExternalEvent {
 /**
  * The message sent by the calling script.
  * `optional`
  * 
  * The message sent by the calling script.
  */
 final dynamic message;

 final MessageSender sender;

 /**
  * Function to call (at most once) when you have a response. The argument
  * should be any JSON-ifiable object. If you have more than one `onMessage`
  * listener in the same document, then only one may send a response. This
  * function becomes invalid when the event listener returns, unless you return
  * true from the event listener to indicate you wish to send a response
  * asynchronously (this will keep the message channel open to the other end
  * until `sendResponse` is called).
  */
 final dynamic sendResponse;

 OnMessageExternalEvent(this.message, this.sender, this.sendResponse);
}

Constructors

new OnMessageExternalEvent(message, MessageSender sender, sendResponse) #

Creates a new Object instance.

Object instances have no meaningful state, and are only useful through their identity. An Object instance is equal to itself only.

docs inherited from Object
OnMessageExternalEvent(this.message, this.sender, this.sendResponse);

Properties

final message #

The message sent by the calling script. optional

The message sent by the calling script.

final dynamic message

final MessageSender sender #

final MessageSender sender

final sendResponse #

Function to call (at most once) when you have a response. The argument should be any JSON-ifiable object. If you have more than one onMessage listener in the same document, then only one may send a response. This function becomes invalid when the event listener returns, unless you return true from the event listener to indicate you wish to send a response asynchronously (this will keep the message channel open to the other end until sendResponse is called).

final dynamic sendResponse