backend-plugin-api: allow service factories to be sync

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2023-01-14 12:46:29 +01:00
parent c1369c2cf4
commit f8c313f80f
5 changed files with 74 additions and 15 deletions
+2 -2
View File
@@ -2,7 +2,7 @@
'@backstage/backend-plugin-api': patch
---
The `createServiceFactory` function has been updated to no longer use a duplicate callback pattern for plugin scoped services. The outer callback is now replaced by an optional `createRootContext` method. This change was made in order to support TypeScript 4.9, but it also simplifies the API surface a bit, especially for plugin scoped service factories that don't need to create a root context.
The `createServiceFactory` function has been updated to no longer use a duplicate callback pattern for plugin scoped services. The outer callback is now replaced by an optional `createRootContext` method. This change was made in order to support TypeScript 4.9, but it also simplifies the API surface a bit, especially for plugin scoped service factories that don't need to create a root context. In addition, the factory and root context functions can now be synchronous.
A factory that previously would have looked like this:
@@ -49,7 +49,7 @@ createServiceFactory({
rootLogger: coreServices.rootLogger,
plugin: coreServices.pluginMetadata,
},
async factory({ rootLogger, plugin }) {
factory({ rootLogger, plugin }) {
return rootLogger.child({ plugin: plugin.getId() });
},
});