(
moduleRef: Module,
instanceWrapper: InstanceWrapper<T | Promise<T>>,
resolutionContext: ResolutionContext = { contextId: STATIC_CONTEXT },
)
| 544 | } |
| 545 | |
| 546 | public async resolveComponentHost<T>( |
| 547 | moduleRef: Module, |
| 548 | instanceWrapper: InstanceWrapper<T | Promise<T>>, |
| 549 | resolutionContext: ResolutionContext = { contextId: STATIC_CONTEXT }, |
| 550 | ): Promise<InstanceWrapper> { |
| 551 | const inquirerId = this.getContextInquirerId(resolutionContext); |
| 552 | const instanceHost = instanceWrapper.getInstanceByContextId( |
| 553 | this.getContextId(resolutionContext.contextId, instanceWrapper), |
| 554 | inquirerId, |
| 555 | ); |
| 556 | if (!instanceHost.isResolved && !instanceWrapper.forwardRef) { |
| 557 | resolutionContext.inquirer?.settlementSignal?.insertRef( |
| 558 | instanceWrapper.id, |
| 559 | ); |
| 560 | |
| 561 | await this.loadProvider( |
| 562 | instanceWrapper, |
| 563 | instanceWrapper.host ?? moduleRef, |
| 564 | resolutionContext, |
| 565 | ); |
| 566 | } else if ( |
| 567 | !instanceHost.isResolved && |
| 568 | instanceWrapper.forwardRef && |
| 569 | (resolutionContext.contextId !== STATIC_CONTEXT || !!inquirerId) |
| 570 | ) { |
| 571 | /** |
| 572 | * When circular dependency has been detected between |
| 573 | * either request/transient providers, we have to asynchronously |
| 574 | * resolve instance host for a specific contextId or inquirer, to ensure |
| 575 | * that eventual lazily created instance will be merged with the prototype |
| 576 | * instantiated beforehand. |
| 577 | */ |
| 578 | instanceHost.donePromise && |
| 579 | void instanceHost.donePromise |
| 580 | .then(() => |
| 581 | this.loadProvider(instanceWrapper, moduleRef, resolutionContext), |
| 582 | ) |
| 583 | .catch(err => { |
| 584 | instanceWrapper.settlementSignal?.error(err); |
| 585 | }); |
| 586 | } |
| 587 | if (instanceWrapper.async) { |
| 588 | const host = instanceWrapper.getInstanceByContextId( |
| 589 | this.getContextId(resolutionContext.contextId, instanceWrapper), |
| 590 | inquirerId, |
| 591 | ); |
| 592 | host.instance = await host.instance; |
| 593 | instanceWrapper.setInstanceByContextId( |
| 594 | resolutionContext.contextId, |
| 595 | host, |
| 596 | inquirerId, |
| 597 | ); |
| 598 | } |
| 599 | return instanceWrapper; |
| 600 | } |
| 601 | |
| 602 | public async lookupComponent<T = any>( |
| 603 | providers: Map<Function | string | symbol, InstanceWrapper>, |
no test coverage detected