Last active
March 25, 2022 03:32
-
-
Save jtlapp/aef6754c4b0e153482c3be48c662dbb4 to your computer and use it in GitHub Desktop.
Example of binding to main APIs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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