1.0.5 • Published 3 years ago
web-bridge-gateway
Licence
ISC
Version
1.0.5
Deps
0
Size
9 kB
Vulns
0
Weekly
0
Web Bridge Gateway
Web-Bridge-Gateway is a wrapper of WebviewJavascriptBridge
Install
yarn
yarn add web-bridge-gateway
npm
npm i web-bridge-gateway
Configurations (Options)
| Key | Type | Default | Description |
|---|---|---|---|
| delay | Number | 200 |
The processing of registerHandler failure caused by birdge initialization takes time, delay call time, value ms |
Methods
callHandler
- **description**: Communicate between native app and mini app. The first parameter is the name provided by native app, the second parameter (optional) is the request body.
```js import { callHandler } from 'web-bridge-gateway'callHandler("setBarTitle", { title: "Home Page" }) .then(() => { // do something }) .catch(() => { // handle error });
registerHandler
- **description**: Register a handler for listening to native app call. The first parameter a name that will be provided by native app, the second parameter is a callback function (optional).
```js import { registerHandler } from 'web-bridge-gateway'registerHandler("myListener", (data, callback) => { console.log("data from native:", data); callback('callback to native'); });