Skip to content

Commit

Permalink
refactor(core): update ResolutionParams with getActivations
Browse files Browse the repository at this point in the history
  • Loading branch information
notaphplover committed Dec 5, 2024
1 parent e51d612 commit 2a1520a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'reflect-metadata';
import { Newable, Right, ServiceIdentifier } from '@inversifyjs/common';
import { getReflectMetadata } from '@inversifyjs/reflect-metadata-utils';

import { BindingActivation } from '../../binding/models/BindingActivation';
import { bindingScopeValues } from '../../binding/models/BindingScope';
import { bindingTypeValues } from '../../binding/models/BindingType';
import { ConstantValueBinding } from '../../binding/models/ConstantValueBinding';
Expand All @@ -15,6 +16,7 @@ import { InstanceBinding } from '../../binding/models/InstanceBinding';
import { Provider } from '../../binding/models/Provider';
import { ProviderBinding } from '../../binding/models/ProviderBinding';
import { ServiceRedirectionBinding } from '../../binding/models/ServiceRedirectionBinding';
import { ActivationsService } from '../../binding/services/ActivationsService';
import { BindingService } from '../../binding/services/BindingService';
import { BindingServiceImplementation } from '../../binding/services/BindingServiceImplementation';
import { isPromise } from '../../common/calculations/isPromise';
Expand Down Expand Up @@ -65,6 +67,7 @@ describe(resolve.name, () => {
let serviceRedirectionBinding: ServiceRedirectionBinding<unknown>;
let serviceRedirectionToNonExistentBinding: ServiceRedirectionBinding<unknown>;

let activationService: ActivationsService;
let bindingService: BindingService;
let getClassMetadataFunction: (type: Newable) => ClassMetadata;

Expand Down Expand Up @@ -172,6 +175,7 @@ describe(resolve.name, () => {
type: bindingTypeValues.ServiceRedirection,
};

activationService = new ActivationsService();
bindingService = new BindingServiceImplementation();

bindingService.set(constantValueBinding);
Expand Down Expand Up @@ -247,6 +251,12 @@ describe(resolve.name, () => {

return resolve({
context: resolutionContext,
getActivations: <TActivated>(
serviceIdentifier: ServiceIdentifier,
): BindingActivation<TActivated>[] | undefined =>
activationService.get(serviceIdentifier) as
| BindingActivation<TActivated>[]
| undefined,
planResult,
requestScopeCache: new Map(),
}) as TMultiple extends false
Expand Down Expand Up @@ -420,6 +430,12 @@ describe(resolve.name, () => {

result = resolve({
context: resolutionContext,
getActivations: <TActivated>(
serviceIdentifier: ServiceIdentifier,
): BindingActivation<TActivated>[] | undefined =>
activationService.get(serviceIdentifier) as
| BindingActivation<TActivated>[]
| undefined,
planResult,
requestScopeCache: new Map(),
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import { ServiceIdentifier } from '@inversifyjs/common';

import { BindingActivation } from '../../binding/models/BindingActivation';
import { PlanResult } from '../../planning/models/PlanResult';
import { ResolutionContext } from './ResolutionContext';

export interface ResolutionParams {
context: ResolutionContext;
getActivations: <TActivated>(
serviceIdentifier: ServiceIdentifier<TActivated>,
) => BindingActivation<TActivated>[] | undefined;
planResult: PlanResult;
requestScopeCache: Map<number, unknown>;
}

0 comments on commit 2a1520a

Please sign in to comment.