backend-plugin-api: made defaultFactories internal

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 10:57:50 +02:00
parent c2b7cb1373
commit 2c57c0c499
4 changed files with 28 additions and 9 deletions
@@ -28,15 +28,20 @@ export type ServiceRef<T> = {
*/
T: T;
toString(): string;
$$ref: 'service';
};
/**
* @internal
*/
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>>;
toString(): string;
$$ref: 'service';
__defaultFactory?: (service: ServiceRef<T>) => Promise<ServiceFactory<T>>;
};
/** @public */
@@ -70,12 +75,12 @@ export function createServiceRef<T>(options: {
get T(): T {
throw new Error(`tried to read ServiceRef.T of ${this}`);
},
defaultFactory,
toString() {
return `serviceRef{${options.id}}`;
},
$$ref: 'service', // TODO: declare
};
__defaultFactory: defaultFactory,
} as InternalServiceRef<T>;
}
/**