backend-next: widen accepted ServiceFactory types to include meta method

Co-authored-by: Fredrik Adelöw <freben@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-09-02 16:27:29 +02:00
parent 5f388ca501
commit 5263e9449d
5 changed files with 33 additions and 22 deletions
@@ -41,7 +41,9 @@ export type InternalServiceRef<T> = ServiceRef<T> & {
* The default factory that will be used to create service
* instances if no other factory is provided.
*/
__defaultFactory?: (service: ServiceRef<T>) => Promise<ServiceFactory<T>>;
__defaultFactory?: (
service: ServiceRef<T>,
) => Promise<ServiceFactory<T> | (() => ServiceFactory<T>)>;
};
/** @public */
@@ -67,7 +69,9 @@ export type ServiceFactory<TService = unknown> = {
*/
export function createServiceRef<T>(options: {
id: string;
defaultFactory?: (service: ServiceRef<T>) => Promise<ServiceFactory<T>>;
defaultFactory?: (
service: ServiceRef<T>,
) => Promise<ServiceFactory<T> | (() => ServiceFactory<T>)>;
}): ServiceRef<T> {
const { id, defaultFactory } = options;
return {