Interface: WebjsContext<O>

This type specifies the shape of the object passed to Web features scripts.

Type parameters

NameTypeDescription
O{}A type describing the shape of the JSON-serializable object given by the shell.

Hierarchy

  • WebjsContext

Properties

options

• Readonly options: O

The options to customize the script behavior.


utils

• utils: DOMUtils

A collection of utilities to manipulate the DOM.

Methods

info

â–¸ info(message: string): void

Safely post an info message to the console. The message will be routed to shell and printed in the React Native console during development.

Parameters:

NameType
messagestring

Returns: void


makeCallbackSafe

â–¸ makeCallbackSafe<T>(callback: T): T

Create a function which execute a callback in a try-catch block that will grab errors en send them to the Webshell component.

Type parameters:

NameType
TFunction

Parameters:

NameTypeDescription
callbackTThe callback to try-catch.

Returns: T


onShellMessage

â–¸ onShellMessage<P>(eventId: string, handler: (payload: P) => void): void

Register a handler on messages sent from the shell.

Type parameters:

NameDescription
PA type describing the shape of the payload sent by shell.

Parameters:

NameTypeDescription
eventIdstringA unique identifier for the event received by the Web script.
handler(payload: P) => void-

Returns: void


postMessageToShell

â–¸ postMessageToShell<P>(payload: P): void

Instruct the shell to send the default event associated with this feature, if any.

Type parameters:

NameDescription
PA type describing the shape of the payload sent to shell.

Parameters:

NameTypeDescription
payloadPThe value which will be passed to the handler.

Returns: void

â–¸ postMessageToShell<P>(eventId: string, payload: P): void

Instruct the shell to call the handler associated with this feature and eventId, if any.

Type parameters:

NameDescription
PA type describing the shape of the payload sent to shell.

Parameters:

NameTypeDescription
eventIdstringA unique identifier for the event sent to the shell. You can omit this param if you are sending a "default" event identifier.
payloadPThe value which will be passed to the handler.

Returns: void


warn

â–¸ warn(message: string): void

Safely post a warn message to the console. The message will be routed to shell and printed in the React Native console during development.

Parameters:

NameType
messagestring

Returns: void