document, and using the messaging methods can communicate with the runtime. See DOM calls in the C3 runtime for more information.
- AddRuntimeMessageHandler(handler, callback)
- Add a callback to be run to handle a message posted from a runtime-side script. The handler is a string identifier. The callback receives the posted data as an argument. Note that if the caller in the runtime-side script originally used the
PostToDOMAsync method, the callback may be an
async function, and the return value is posted back to the runtime-side script. The
AddRuntimeMessageHandlers variant accepts an array of
[handler, callback] which is convenient when adding multiple handlers.
- PostToRuntime(handler, data)
- PostToRuntimeAsync(handler, data)
- Post a message to a runtime-side script. The handler is a string identifier. The
data must be structurally clonable (since it is posted down a MessageChannel). The async method returns a promise that resolves with the runtime-side callback's return value. The non-async method does not return a value and the runtime-side callback's return value is discarded (i.e. a "fire and forget" message).
Addon SDK Manual
You are here:
Search this manual:
This manual entry was last updated on 10 Dec, 2020 at 15:02