Skip to content

Commit 0afbcee

Browse files
committed
Added error
1 parent d2a1bfb commit 0afbcee

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/di/di.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,11 @@ export default function Inject(target, key, index?: number): any {
273273
(target[injectServiceKeysSymbol] ??= {})[key] = pType;
274274
const descriptor = {
275275
get() {
276-
const result = ServiceProvider.resolve(this, pType);
276+
const sp = this[serviceProvider] as ServiceProvider;
277+
if (!sp) {
278+
throw new Error("No service provider registered, in case if want to initialize service object in constructor, please dervie from ServiceObject")
279+
}
280+
const result = sp.resolve(pType);
277281
// get is compatible with AtomWatcher
278282
// as it will ignore getter and it will
279283
// not try to set a binding refresher

0 commit comments

Comments
 (0)