5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-03 21:12:11 +08:00
wails/runtime/js/core/ipc.js
Lea Anthony 914642bd1d
Backport (#283)
* Develop (#265)


* Patch for file dialog on OSX

* Update CONTRIBUTORS.md

* 262 add wails shutdown method (#264)

* feat: support close in bridge mode

* feat: WailsShutdown callback

Now handles proper shutdown through:
  * runtime.Window.Close()
  * Killing the main window
  * Ctrl-C

* chore: version bump

* chore: version bump

* feat: adjust binary name for OS

* fix: allow spaces in gcc path

* feat: migrate command

* fix: npm/node versions

* fix: allow IE for serve

* feat: go build script

* fix: make runtime ES2015 compliant

* fix: remove invoke patch

* fix: allow any line endings

* chore: remove legacy bridge files

* chore: latest assets
2019-11-02 21:06:02 +11:00

42 lines
811 B
JavaScript

/*
_ __ _ __
| | / /___ _(_) /____
| | /| / / __ `/ / / ___/
| |/ |/ / /_/ / / (__ )
|__/|__/\__,_/_/_/____/
The lightweight framework for web-like apps
(c) Lea Anthony 2019-present
*/
/* jshint esversion: 6 */
/**
* Invoke sends the given message to the backend
*
* @param {string} message
*/
function Invoke(message) {
if ( window.wailsbridge ) {
window.wailsbridge.websocket.send(message);
} else {
window.external.invoke(message);
}
}
/**
* Sends a message to the backend based on the given type, payload and callbackID
*
* @export
* @param {string} type
* @param {string} payload
* @param {string=} callbackID
*/
export function SendMessage(type, payload, callbackID) {
const message = {
type,
callbackID,
payload
};
Invoke(JSON.stringify(message));
}