thunder-webview
v1.10.1
Published
A basic JS wrapper around various webview messaging systems, allowing for an easy interface to interact with.
Downloads
8
Maintainers
Readme
This is a small library to normalize webview messaging with different browser engines. This is not fully tested with every browser engine at this point.
This project is part of the Thunder.WebView project which is C# library for writing a multi-platform webview in a more native manner without requiring node (aka Electron).
To use, in a hosted webview, you can either add the browser script manually:
//include script
<scripts src="/dist/thunder.webview.browser.js" />
//create request object
var request = {
RequestId: "requestId",
Message: {} // object to be parsed as the message handler args
};
//using callbacks
_webview.sendRequest(request, function(response)
{
//do something with response
});
//or using async/await
var response = await _webview.sendRequestAsync(request)
If you don't want the global scope _webview (e.g. want to reference the module), you can reference WebViewMessenger
directly instead:
//import
import {WebViewMessenger} from "thunder-webview/lib/webViewMessenger"
var messenger = new WebViewMessenger();
//using callbacks
messenger.sendRequest(request, function(response)
{
//do something with response
});
//or using async/await
var response = await messenger.sendRequestAsync(request)