5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 03:20:09 +08:00

Example bindings

This commit is contained in:
Lea Anthony 2023-02-27 20:05:54 +11:00
parent 00c458f948
commit 443ea46d1d
2 changed files with 29 additions and 2 deletions

View File

@ -0,0 +1,26 @@
function GreetService(method) {
return {
packageName: "main",
serviceName: "GreetService",
methodName: method,
args: Array.prototype.slice.call(arguments, 1),
};
}
/**
* GreetService.Greet
* Greet someone
* @param name {string}
* @returns {Promise<string>}
*/
function Greet(name) {
return wails.Call(GreetService("Greet", name));
}
window.go = {
main: {
GreetService: {
Greet,
}
}
};

View File

@ -37,6 +37,7 @@ export function callCallback(id, data, isJSON) {
callResponses.delete(id);
}
}
export function callErrorCallback(id, message) {
let p = callResponses.get(id);
if (p) {
@ -45,7 +46,7 @@ export function callErrorCallback(id, message) {
}
}
function dialog(type, options) {
function callBinding(type, options) {
return new Promise((resolve, reject) => {
let id = generateID();
options = options || {};
@ -60,6 +61,6 @@ function dialog(type, options) {
export function Call(options) {
return dialog("Call", options);
return callBinding("Call", options);
}