aklinker1 / webext-core

Collection of essential libraries and tools for building web extensions
https://webext-core.aklinker1.io
MIT License
96 stars 11 forks source link

feat(proxy-service): Support raw functions and nested objects #16

Closed aklinker1 closed 1 year ago

aklinker1 commented 1 year ago

This closes #15.

The proxy service package now supports objects and functions at any depth:

defineProxyService("getOne", () => async () => 1);

defineProxyService("NumberService", () => ({
  getOne: async () => 1,
}));

defineProxyService("API", () => ({
  numberService: {
    getOne: async () => 1,
  },
}));
aklinker1 commented 1 year ago

As it is implemented now, there is a breaking change to types: your proxied functions must be async, and objects cannot contain additional properties. I got the initial implementation working with this change, but I'd like to make it non-breaking. So I'm gonna take a crack at that.

aklinker1 commented 1 year ago

Alright, it shouldn't be breaking anymore. This should be good to go.