Static Methods
-
Dispatcher._ChromeRuntimeTransport() common/network/dispatcher.js, line 349
-
Creates a new Dispatcher transport to communicate with windows, tabs, extensions, or apps via chrome.runtime.connect.
This transport can only be used in priviledged code (e.g. code inside content scripts, extensions, or apps), as it requires access to chrome.runtime.connect.
-
Dispatcher._PostMessageTransport(otherWindowOrIframe) common/network/dispatcher.js, line 281
-
Creates a new Dispatcher transport to with another window via postMessage.
Argument Type Description otherWindowOrIframeWindow | HTMLIFrameElement A window to communicate with.
-
Dispatcher._WebsocketTransport(url) common/network/dispatcher.js, line 215
-
Creates a new Dispatcher transport to communicate over a websocket.
Argument Type Description urlString URL to connect to.
Instance Methods
-
callRPC(name, data, callback, traceId) common/network/dispatcher.js, line 156
-
Calls an RPC. Use
Dispatcher#registerRPCorDispatcher#registerAsyncRPCto register a handler for an RPC.Argument Type Attributes Description nameString Name of the RPC.
dataObject Arbitrary data argument.
callbackfunction Callback that receives the result of the RPC.
traceIdString <optional>
A trace ID for the event. If not given, one will be randomly generated.
-
fireEvent(name, data, traceId) common/network/dispatcher.js, line 131
-
Fires an event. Use
Dispatcher#subscribeon the other side to listen for events. The event will be fired locally, as well, so any subscribers for the event attached to this Dispatcher will be called.Argument Type Attributes Description nameString Name of the event.
dataObject <optional>
Event data.
traceIdString <optional>
A trace ID for the event. If not given, one will be randomly generated.
-
registerAsyncRPC(name, handler) common/network/dispatcher.js, line 200
-
Creates a new RPC. This version requires that the RPC asynchronously returns a value, see
Dispatcher#registerAsyncRPCfor a version that allows for synchrony.Argument Type Description nameString Name of the RPC.
handlerfunction Gets the a data object as the first argument, a callback as the second argument, and a trace id as the third argument. Must invoke the callback, passing in the result of the RPC.
-
registerRPC(name, handler) common/network/dispatcher.js, line 184
-
Creates a new RPC. This version requires that the RPC synchronously returns a value, see
Dispatcher#registerAsyncRPCfor a version that allows for asynchrony.Argument Type Description nameString Name of the RPC.
handlerfunction Gets the a data object as the first argument and the trace id as the second argument. Must return the result of the RPC.
-
subscribe(eventName, subscriber) → {Binding} common/network/dispatcher.js, line 112
-
Subscribes a function to be called whenever this Dispatcher receives a particular event. Use
Dispatcher#fireEventon the other side to fire an event.
Returns:Argument Type Description eventNameString Name of the event.
subscriberfunction Function to call when the event is received. Gets the message data as the first argument and the trace id as the second argument.
A binding, allowing the subscription to be cancelled later.