1.0.8 • Published 2 years ago

@dead_fish/jsbridge v1.0.8

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago
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>
1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago