Class: Feature<O, P, W>
A feature encapsulates injectable behaviors in a WebView.
remarks
You should never instantiate that class directly. Use FeatureBuilder instead.
Type parameters
Name | Type | Default | Description |
---|---|---|---|
O | {} | {} | A type describing the shape of the JSON-serializable object that will be passed to the Web script. |
P | PropsSpecs<any, any> | {} | A type specifying the new properties added to the shell (capabilities to send message to the shell). |
W | WebHandlersSpecs<any> | {} | A type specifying the Web handlers added to the shell (capabilities to send message to the Web script). |
Hierarchy
- Feature
Implements
- { defaultOptions: Required<O> ; identifier: string ; script: string }
Constructors
constructor
+ Protected
new Feature(params
: FeatureDefinition<O> & { propSpecs: P ; webSpecs: W }, options
: O): Feature
Parameters:
Name | Type |
---|---|
params | FeatureDefinition<O> & { propSpecs: P ; webSpecs: W } |
options | O |
Returns: Feature
Properties
defaultOptions
• Readonly
defaultOptions: Required<O>
These options will be shallow-merged with the options provided to the FeatureClass.
identifier
• Readonly
identifier: string
A unique identifier of the feature. The convention is to use a reverse namespace domain ending with the feature name.
example
org.formidable-webview/webshell.link-press
options
• Readonly
options: O
The options that will be passed to the Web script.
propSpecs
• Readonly
propSpecs: P
An object specifying which props this feature will add to the shell.
script
• Readonly
script: string
The string containing valid ECMAScript 5 to be run in the WebView.
remarks
The script must define a single function which only argument is of the
type WebjsContext.
It is recommended that you use eslint to validate this script syntax, and event better, unit-test the script. See our repository home page for more information.
webSpecs
• Readonly
webSpecs: W
An object specifying which handlers this feature Web script will support.
Methods
hasWebHandler
â–¸ hasWebHandler(eventId
: string): boolean
internal
Parameters:
Name | Type |
---|---|
eventId | string |
Returns: boolean