Interface: WebjsContext<O>
This type specifies the shape of the object passed to Web features scripts.
Type parameters
Name | Type | Description |
---|---|---|
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:
Name | Type |
---|---|
message | string |
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:
Name | Type |
---|---|
T | Function |
Parameters:
Name | Type | Description |
---|---|---|
callback | T | The 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:
Name | Description |
---|---|
P | A type describing the shape of the payload sent by shell. |
Parameters:
Name | Type | Description |
---|---|---|
eventId | string | A 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:
Name | Description |
---|---|
P | A type describing the shape of the payload sent to shell. |
Parameters:
Name | Type | Description |
---|---|---|
payload | P | The 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:
Name | Description |
---|---|
P | A type describing the shape of the payload sent to shell. |
Parameters:
Name | Type | Description |
---|---|---|
eventId | string | A unique identifier for the event sent to the shell. You can omit this param if you are sending a "default" event identifier. |
payload | P | The 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:
Name | Type |
---|---|
message | string |
Returns: void