Skip to content

Instantly share code, notes, and snippets.

@jtlapp
Last active March 25, 2022 03:32
Show Gist options
  • Save jtlapp/aef6754c4b0e153482c3be48c662dbb4 to your computer and use it in GitHub Desktop.
Save jtlapp/aef6754c4b0e153482c3be48c662dbb4 to your computer and use it in GitHub Desktop.
Example of binding to main APIs
import type { MainApi1 } from '../backend/apis/main_api_1.ts';
import type { MainApi2 } from '../backend/apis/main_api_2.ts';
async function bindMainApis() {
return {
mainApi1: await bindMainApi<MainApi1>("MainApi1"),
mainApi2: await bindMainApi<MainApi2>("MainApi2"),
/* ... */
};
}
async function doWork() {
const apis = await bindMainApis();
await apis.mainApi1.methodA("foo", 32);
const returnValue = await apis.mainApi1.methodB();
/* ... */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment