@dead_fish/jsbridge
v1.0.8
Published
A lightweight and easy-to-use jsBridge for Android and IOS platforms.
Downloads
18
Maintainers
Readme
npm install @dead_fish/jsbridge
Native IOS or Native Android communication bridge for webview. H5 and Native communication bridge.
JsBridge is a lightweight bridge for communication between webview and native. IOS and Android are supported
Usage
ES
import { jsBridge, utils } from '@dead_fish/jsbridge';
const query = utils.parseUrl()
jsBridge.registerHandler({
eventName: 'eventName',
handler: function (data, callback) {
console.log(data);
}
})
jsBridge.callHandler({
eventName: 'eventName',
data: {},
handler: function (response) {
console.log(response)
}
})
CommonJS
const { jsBridge, utils } = require('@dead_fish/jsbridge');
const query = utils.parseUrl()
jsBridge.registerHandler({
eventName: 'eventName',
handler: function (data, callback) {
console.log(data);
}
})
jsBridge.callHandler({
eventName: 'eventName',
data: {},
handler: function (response) {
console.log(response)
}
})
Browser
<script src="./node_modules/@dead_fish/jsbridge/dist/bundle.umd.js"></script>
<script>
const jsBridge = window.dhLib.jsBridge;
const utils = window.dhLib.utils;
const query = utils.parseUrl()
jsBridge.registerHandler({
eventName: 'eventName',
handler: function (data, callback) {
console.log(data);
}
})
jsBridge.callHandler({
eventName: 'eventName',
data: {},
handler: function (response) {
console.log(response)
}
})
</script>