-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #152 from inversify/refactor/update-bindings-with-…
…consistent-activated-generic Update bindings with consistent activated generic
- Loading branch information
Showing
19 changed files
with
94 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 6 additions & 3 deletions
9
packages/container/libraries/core/src/binding/models/Binding.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
import { ConstantValueBinding } from './ConstantValueBinding'; | ||
import { DynamicValueBinding } from './DynamicValueBinding'; | ||
import { Factory } from './Factory'; | ||
import { FactoryBinding } from './FactoryBinding'; | ||
import { InstanceBinding } from './InstanceBinding'; | ||
import { Provider } from './Provider'; | ||
import { ProviderBinding } from './ProviderBinding'; | ||
import { ServiceRedirectionBinding } from './ServiceRedirectionBinding'; | ||
|
||
export type Binding<TActivated> = | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export type Binding<TActivated = any> = | ||
| ConstantValueBinding<TActivated> | ||
| DynamicValueBinding<TActivated> | ||
| FactoryBinding<TActivated> | ||
| (TActivated extends Factory<unknown> ? FactoryBinding<TActivated> : never) | ||
| InstanceBinding<TActivated> | ||
| ProviderBinding<TActivated> | ||
| (TActivated extends Provider<unknown> ? ProviderBinding<TActivated> : never) | ||
| ServiceRedirectionBinding<TActivated>; |
3 changes: 2 additions & 1 deletion
3
packages/container/libraries/core/src/binding/models/DynamicValueBuilder.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { ResolutionContext } from '../../resolution/models/ResolutionContext'; | ||
import { Resolved } from '../../resolution/models/Resolved'; | ||
|
||
export type DynamicValueBuilder<T> = ( | ||
context: ResolutionContext, | ||
) => T | Promise<T>; | ||
) => Resolved<T>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 8 additions & 9 deletions
17
packages/container/libraries/core/src/planning/models/LeafBindingNode.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
import { ConstantValueBinding } from '../../binding/models/ConstantValueBinding'; | ||
import { DynamicValueBinding } from '../../binding/models/DynamicValueBinding'; | ||
import { Factory } from '../../binding/models/Factory'; | ||
import { FactoryBinding } from '../../binding/models/FactoryBinding'; | ||
import { Provider } from '../../binding/models/Provider'; | ||
import { ProviderBinding } from '../../binding/models/ProviderBinding'; | ||
import { BaseBindingNode } from './BaseBindingNode'; | ||
|
||
export type LeafBindingNode = BaseBindingNode< | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| ConstantValueBinding<any> | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| DynamicValueBinding<any> | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| FactoryBinding<any> | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| ProviderBinding<any> | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export type LeafBindingNode<TActivated = any> = BaseBindingNode< | ||
| ConstantValueBinding<TActivated> | ||
| DynamicValueBinding<TActivated> | ||
| (TActivated extends Factory<unknown> ? FactoryBinding<TActivated> : never) | ||
| (TActivated extends Provider<unknown> ? ProviderBinding<TActivated> : never) | ||
>; |
6 changes: 5 additions & 1 deletion
6
packages/container/libraries/core/src/planning/models/PlanServiceNodeParent.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
import { InstanceBinding } from '../../binding/models/InstanceBinding'; | ||
import { InstanceBindingNode } from './InstanceBindingNode'; | ||
|
||
export type PlanServiceNodeParent = InstanceBindingNode; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export type PlanServiceNodeParent<TActivated = any> = InstanceBindingNode< | ||
InstanceBinding<TActivated> | ||
>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...ontainer/libraries/core/src/resolution/calculations/resolveDynamicValueBindingCallback.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import { DynamicValueBinding } from '../../binding/models/DynamicValueBinding'; | ||
import { ResolutionParams } from '../models/ResolutionParams'; | ||
import { Resolved } from '../models/Resolved'; | ||
|
||
export function resolveDynamicValueBindingCallback<TActivated>( | ||
params: ResolutionParams, | ||
binding: DynamicValueBinding<TActivated>, | ||
): TActivated | Promise<TActivated> { | ||
): Resolved<TActivated> { | ||
return binding.value(params.context); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
packages/container/libraries/core/src/resolution/models/Resolved.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export type Resolved<TActivated> = | ||
| SyncResolved<TActivated> | ||
| Promise<SyncResolved<TActivated>>; | ||
|
||
export type SyncResolved<TActivated> = Awaited<TActivated>; |