......
// during bridge initialization
bridge.addHandler = function(handlerName, handler) {
window.WebViewJavascriptBridge.registerHandler(handlerName, handler);
};
bridge.removeHandler = function(handlerName) {
window.WebViewJavascriptBridge.deregisterHandler(handlerName);
};
......
// Add a handler
bridge.addHandler("handlerA", function(data) { console.log("handlerA called from Pulsar"); });
doSomethingThatMakesPulsarCallHandlerA();
// Remove a handler
bridge.removeHandler("handlerA"); |