fusion-core icon indicating copy to clipboard operation
fusion-core copied to clipboard

Support `async provides` in Fusion.js plugins

Open alxmyth opened this issue 6 years ago • 0 comments

Type of issue

Feature request

Description

Support an async provides method for Fusion.js plugins. These should be resolved prior to being passed in as dependencies to other plugins.

Current behavior

createPlugin({
   deps: {},
   provides: async (deps) => {
      const service: SomeLibraryType = new SomeLibrary();
      await service.init();
      return service;
   }
});

If the above plugin were used as a dependency, it would resolve to Promise<SomeLibraryType>.

Expected behavior

Ideally consumers can use the underlying library directly, and dependents would have access to the underlying service:

createPlugin({
   deps: { someLibrary: SomeLibraryToken },
   provides: (deps) => {
      const someLibrary: SomeLibraryType = deps.someLibrary; // not a Promise
   }
}

alxmyth avatar May 02 '19 23:05 alxmyth