`proxy-service`: Support functions and nested objects
Closed this issue · 0 comments
aklinker1 commented
I'd like to support executing functions directly, or executing functions in deeply nested in objects.
async function doWork() {
...
}
function createSomeService() {
return { doWork };
}
function createBackgroundAPI() {
return {
someService: createSomeService(),
},
}
// ❌ This doesn't work today
const [registerDoWork, getDoWork] = defineProxyService("doWork", () => doWork);
// ✅ This works today
const [registerSomeService, getSomeService] = defineProxyService("SomeService", () => createSomeService());
// ❌ This doesn't work today
const [registerAPI, getAPI] = defineProxyService("API", () => createBackgroundAPI());
They could be used like so:
const doWork = getDoWork();
await doWork();
const someService = getSomeService();
await someService.doWork();
const api = getAPI();
api.someService.doWork();