From 515224488aa5c84f6f8c781a05614ed12fceb0ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Pintos=20L=C3=B3pez?= Date: Sun, 19 Jan 2025 22:26:00 +0100 Subject: [PATCH 1/6] style(inversify-code-examples): update code examples with import normalization comments --- .../src/examples/bindingOnSyntaxApiOnActivation.ts | 1 + .../inversify-code-examples/src/examples/bindingScopeRequest.ts | 1 + .../src/examples/bindingScopeSingleton.ts | 1 + .../src/examples/bindingScopeTransient.ts | 1 + .../inversify-code-examples/src/examples/bindingToSyntaxApiTo.ts | 1 + .../src/examples/bindingToSyntaxApiToAutoFactory.ts | 1 + .../src/examples/bindingToSyntaxApiToAutoNamedFactory.ts | 1 + .../src/examples/bindingToSyntaxApiToConstantValue.ts | 1 + .../src/examples/bindingToSyntaxApiToConstructor.ts | 1 + .../src/examples/bindingToSyntaxApiToDynamicValue.ts | 1 + .../src/examples/bindingToSyntaxApiToFactory.ts | 1 + .../src/examples/bindingToSyntaxApiToProvider.ts | 1 + .../src/examples/bindingToSyntaxApiToSelf.ts | 1 + .../src/examples/bindingToSyntaxApiToService.ts | 1 + .../src/examples/bindingWhenSyntaxApiWhen.ts | 1 + .../inversify-code-examples/src/examples/containerApiGet.ts | 1 + .../inversify-code-examples/src/examples/containerApiGetAll.ts | 1 + .../src/examples/containerApiGetAllAsync.ts | 1 + .../src/examples/containerApiGetAllAsyncEnforced.ts | 1 + .../src/examples/containerApiGetAllEnforced.ts | 1 + .../src/examples/containerApiGetAllNamed.ts | 1 + .../src/examples/containerApiGetAllNamedAsync.ts | 1 + .../src/examples/containerApiGetAllTagged.ts | 1 + .../src/examples/containerApiGetAllTaggedAsync.ts | 1 + .../inversify-code-examples/src/examples/containerApiGetAsync.ts | 1 + .../inversify-code-examples/src/examples/containerApiGetNamed.ts | 1 + .../src/examples/containerApiGetNamedAsync.ts | 1 + .../src/examples/containerApiGetTagged.ts | 1 + .../src/examples/containerApiGetTaggedAsync.ts | 1 + .../inversify-code-examples/src/examples/containerApiIsBound.ts | 1 + .../src/examples/containerApiIsBoundNamed.ts | 1 + .../src/examples/containerApiIsBoundTagged.ts | 1 + .../src/examples/containerApiIsCurrentBound.ts | 1 + .../inversify-code-examples/src/examples/containerApiMerge.ts | 1 + .../src/examples/containerApiOnActivation.ts | 1 + .../src/examples/containerApiOnDeactivation.ts | 1 + .../src/examples/containerApiOptionsAutoBindInjectable.ts | 1 + .../examples/containerApiOptionsAutoBindInjectablePrecedence.ts | 1 + .../src/examples/containerApiOptionsDefaultScope.ts | 1 + .../inversify-code-examples/src/examples/containerApiRebind.ts | 1 + .../inversify-code-examples/src/examples/containerApiResolve.ts | 1 + .../src/examples/containerModuleApiExample.ts | 1 + .../src/examples/decoratorApiInjectConstructorArgument.ts | 1 + .../src/examples/decoratorApiInjectProperty.ts | 1 + .../src/examples/decoratorApiMultiInjectProperty.ts | 1 + .../inversify-code-examples/src/examples/decoratorApiNamed.ts | 1 + .../inversify-code-examples/src/examples/decoratorApiOptional.ts | 1 + .../src/examples/decoratorApiPostConstruct.ts | 1 + .../src/examples/decoratorApiPreDestroy.ts | 1 + .../inversify-code-examples/src/examples/decoratorApiTagged.ts | 1 + .../src/examples/decoratorApiUnmanaged.ts | 1 + .../inversify-code-examples/src/examples/dependencyInversion.ts | 1 + .../tools/inversify-code-examples/src/examples/diHierarchy.ts | 1 + .../tools/inversify-code-examples/src/examples/gettingStarted.ts | 1 + 54 files changed, 54 insertions(+) diff --git a/packages/docs/tools/inversify-code-examples/src/examples/bindingOnSyntaxApiOnActivation.ts b/packages/docs/tools/inversify-code-examples/src/examples/bindingOnSyntaxApiOnActivation.ts index 9f92f72c..3d9aeba8 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/bindingOnSyntaxApiOnActivation.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/bindingOnSyntaxApiOnActivation.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container, injectable, interfaces } from 'inversify'; const container: Container = new Container(); diff --git a/packages/docs/tools/inversify-code-examples/src/examples/bindingScopeRequest.ts b/packages/docs/tools/inversify-code-examples/src/examples/bindingScopeRequest.ts index 46599fce..3df71f0a 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/bindingScopeRequest.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/bindingScopeRequest.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container, inject } from 'inversify'; interface Weapon { diff --git a/packages/docs/tools/inversify-code-examples/src/examples/bindingScopeSingleton.ts b/packages/docs/tools/inversify-code-examples/src/examples/bindingScopeSingleton.ts index b567577a..b0c9c076 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/bindingScopeSingleton.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/bindingScopeSingleton.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container } from 'inversify'; interface Weapon { diff --git a/packages/docs/tools/inversify-code-examples/src/examples/bindingScopeTransient.ts b/packages/docs/tools/inversify-code-examples/src/examples/bindingScopeTransient.ts index d0f62f38..f8d6a1ff 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/bindingScopeTransient.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/bindingScopeTransient.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container } from 'inversify'; interface Weapon { diff --git a/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiTo.ts b/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiTo.ts index 013db91f..a1772685 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiTo.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiTo.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container } from 'inversify'; interface Weapon { diff --git a/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToAutoFactory.ts b/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToAutoFactory.ts index d94848cf..29c61417 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToAutoFactory.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToAutoFactory.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container, inject, injectable, interfaces } from 'inversify'; interface Weapon { diff --git a/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToAutoNamedFactory.ts b/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToAutoNamedFactory.ts index 1ef3f927..1e20fa63 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToAutoNamedFactory.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToAutoNamedFactory.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container, inject, injectable, interfaces } from 'inversify'; interface Weapon { diff --git a/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToConstantValue.ts b/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToConstantValue.ts index 6951fc64..59b14e35 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToConstantValue.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToConstantValue.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container } from 'inversify'; interface Weapon { diff --git a/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToConstructor.ts b/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToConstructor.ts index e58fa5a3..60d95c64 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToConstructor.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToConstructor.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container, interfaces } from 'inversify'; interface Weapon { diff --git a/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToDynamicValue.ts b/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToDynamicValue.ts index 21680071..0b3a9530 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToDynamicValue.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToDynamicValue.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container } from 'inversify'; interface Weapon { diff --git a/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToFactory.ts b/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToFactory.ts index 75944684..d0b0ef0a 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToFactory.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToFactory.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container, inject, injectable, interfaces } from 'inversify'; export interface Engine { diff --git a/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToProvider.ts b/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToProvider.ts index e0964f3e..d20b07bc 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToProvider.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToProvider.ts @@ -1,4 +1,5 @@ /* eslint-disable @typescript-eslint/no-magic-numbers */ +// Is-inversify-import-example import { Container, injectable, interfaces } from 'inversify'; // Begin-example diff --git a/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToSelf.ts b/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToSelf.ts index f4af9843..b4602b8b 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToSelf.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToSelf.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container } from 'inversify'; interface Weapon { diff --git a/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToService.ts b/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToService.ts index 8e80d4e5..819077b3 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToService.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/bindingToSyntaxApiToService.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container } from 'inversify'; interface CardCatalogProvider { diff --git a/packages/docs/tools/inversify-code-examples/src/examples/bindingWhenSyntaxApiWhen.ts b/packages/docs/tools/inversify-code-examples/src/examples/bindingWhenSyntaxApiWhen.ts index aa043d71..c55ff6fe 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/bindingWhenSyntaxApiWhen.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/bindingWhenSyntaxApiWhen.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container, inject, injectable, interfaces, named } from 'inversify'; interface Weapon { diff --git a/packages/docs/tools/inversify-code-examples/src/examples/containerApiGet.ts b/packages/docs/tools/inversify-code-examples/src/examples/containerApiGet.ts index eb259d09..48a15a4b 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/containerApiGet.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/containerApiGet.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container, injectable } from 'inversify'; interface Weapon { diff --git a/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAll.ts b/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAll.ts index 6e37229a..d55a5877 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAll.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAll.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container, injectable } from 'inversify'; interface Weapon { diff --git a/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAllAsync.ts b/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAllAsync.ts index 8a9354e8..b5db96c0 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAllAsync.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAllAsync.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container, injectable } from 'inversify'; interface Weapon { diff --git a/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAllAsyncEnforced.ts b/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAllAsyncEnforced.ts index 8e2836b9..fed62921 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAllAsyncEnforced.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAllAsyncEnforced.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container, injectable } from 'inversify'; interface Weapon { diff --git a/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAllEnforced.ts b/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAllEnforced.ts index 39cf20af..a979b54f 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAllEnforced.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAllEnforced.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container, injectable } from 'inversify'; interface Weapon { diff --git a/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAllNamed.ts b/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAllNamed.ts index 3e182e06..79b81b8f 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAllNamed.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAllNamed.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container } from 'inversify'; // Begin-example diff --git a/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAllNamedAsync.ts b/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAllNamedAsync.ts index 3581352a..dcd018b5 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAllNamedAsync.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAllNamedAsync.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container } from 'inversify'; // Begin-example diff --git a/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAllTagged.ts b/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAllTagged.ts index 2bf6cf54..4ea13213 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAllTagged.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAllTagged.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container } from 'inversify'; // Begin-example diff --git a/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAllTaggedAsync.ts b/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAllTaggedAsync.ts index 86acaeec..11b783f6 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAllTaggedAsync.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAllTaggedAsync.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container } from 'inversify'; // Begin-example diff --git a/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAsync.ts b/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAsync.ts index 08dcd07a..211f5dcb 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAsync.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetAsync.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container, injectable } from 'inversify'; @injectable() diff --git a/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetNamed.ts b/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetNamed.ts index 313e0d2d..b58e4de3 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetNamed.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetNamed.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container, injectable } from 'inversify'; interface Weapon { diff --git a/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetNamedAsync.ts b/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetNamedAsync.ts index 3c4bad4c..077f87d1 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetNamedAsync.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetNamedAsync.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container, injectable } from 'inversify'; interface Weapon { diff --git a/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetTagged.ts b/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetTagged.ts index c72e0d74..60c9424e 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetTagged.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetTagged.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container, injectable } from 'inversify'; interface Weapon { diff --git a/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetTaggedAsync.ts b/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetTaggedAsync.ts index bb7f8aa6..4d3fc410 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetTaggedAsync.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/containerApiGetTaggedAsync.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container, injectable } from 'inversify'; interface Weapon { diff --git a/packages/docs/tools/inversify-code-examples/src/examples/containerApiIsBound.ts b/packages/docs/tools/inversify-code-examples/src/examples/containerApiIsBound.ts index 73a297e1..425d96c2 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/containerApiIsBound.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/containerApiIsBound.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container, injectable } from 'inversify'; // Begin-example diff --git a/packages/docs/tools/inversify-code-examples/src/examples/containerApiIsBoundNamed.ts b/packages/docs/tools/inversify-code-examples/src/examples/containerApiIsBoundNamed.ts index 12793f0f..6cca2040 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/containerApiIsBoundNamed.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/containerApiIsBoundNamed.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container } from 'inversify'; // Begin-example diff --git a/packages/docs/tools/inversify-code-examples/src/examples/containerApiIsBoundTagged.ts b/packages/docs/tools/inversify-code-examples/src/examples/containerApiIsBoundTagged.ts index 23cdd290..7b568947 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/containerApiIsBoundTagged.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/containerApiIsBoundTagged.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container } from 'inversify'; // Begin-example diff --git a/packages/docs/tools/inversify-code-examples/src/examples/containerApiIsCurrentBound.ts b/packages/docs/tools/inversify-code-examples/src/examples/containerApiIsCurrentBound.ts index 85af58af..191b050f 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/containerApiIsCurrentBound.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/containerApiIsCurrentBound.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container, injectable } from 'inversify'; // Begin-example diff --git a/packages/docs/tools/inversify-code-examples/src/examples/containerApiMerge.ts b/packages/docs/tools/inversify-code-examples/src/examples/containerApiMerge.ts index 07b37ca4..42d512c1 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/containerApiMerge.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/containerApiMerge.ts @@ -1,4 +1,5 @@ /* eslint-disable @typescript-eslint/typedef */ +// Is-inversify-import-example import { Container, injectable, interfaces } from 'inversify'; // Begin-example diff --git a/packages/docs/tools/inversify-code-examples/src/examples/containerApiOnActivation.ts b/packages/docs/tools/inversify-code-examples/src/examples/containerApiOnActivation.ts index 2c92b873..2f8f8490 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/containerApiOnActivation.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/containerApiOnActivation.ts @@ -1,4 +1,5 @@ /* eslint-disable @typescript-eslint/no-magic-numbers */ +// Is-inversify-import-example import { Container, interfaces } from 'inversify'; // Begin-example diff --git a/packages/docs/tools/inversify-code-examples/src/examples/containerApiOnDeactivation.ts b/packages/docs/tools/inversify-code-examples/src/examples/containerApiOnDeactivation.ts index c922e5e1..746c13cc 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/containerApiOnDeactivation.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/containerApiOnDeactivation.ts @@ -1,5 +1,6 @@ import { jest } from '@jest/globals'; +// Is-inversify-import-example import { Container } from 'inversify'; // Begin-example diff --git a/packages/docs/tools/inversify-code-examples/src/examples/containerApiOptionsAutoBindInjectable.ts b/packages/docs/tools/inversify-code-examples/src/examples/containerApiOptionsAutoBindInjectable.ts index e01d01c9..fbe60024 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/containerApiOptionsAutoBindInjectable.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/containerApiOptionsAutoBindInjectable.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container } from 'inversify'; class Ninja {} diff --git a/packages/docs/tools/inversify-code-examples/src/examples/containerApiOptionsAutoBindInjectablePrecedence.ts b/packages/docs/tools/inversify-code-examples/src/examples/containerApiOptionsAutoBindInjectablePrecedence.ts index 7c14df68..0e73a8be 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/containerApiOptionsAutoBindInjectablePrecedence.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/containerApiOptionsAutoBindInjectablePrecedence.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container } from 'inversify'; export class Ninja {} diff --git a/packages/docs/tools/inversify-code-examples/src/examples/containerApiOptionsDefaultScope.ts b/packages/docs/tools/inversify-code-examples/src/examples/containerApiOptionsDefaultScope.ts index d284ee87..a40c2a58 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/containerApiOptionsDefaultScope.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/containerApiOptionsDefaultScope.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container } from 'inversify'; type Warrior = unknown; diff --git a/packages/docs/tools/inversify-code-examples/src/examples/containerApiRebind.ts b/packages/docs/tools/inversify-code-examples/src/examples/containerApiRebind.ts index 916f21ce..4a476ad1 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/containerApiRebind.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/containerApiRebind.ts @@ -1,4 +1,5 @@ /* eslint-disable @typescript-eslint/no-magic-numbers */ +// Is-inversify-import-example import { Container } from 'inversify'; // Begin-example diff --git a/packages/docs/tools/inversify-code-examples/src/examples/containerApiResolve.ts b/packages/docs/tools/inversify-code-examples/src/examples/containerApiResolve.ts index 7a252d98..e0caf61e 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/containerApiResolve.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/containerApiResolve.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container, injectable } from 'inversify'; @injectable() diff --git a/packages/docs/tools/inversify-code-examples/src/examples/containerModuleApiExample.ts b/packages/docs/tools/inversify-code-examples/src/examples/containerModuleApiExample.ts index f81bd035..161e2481 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/containerModuleApiExample.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/containerModuleApiExample.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container, ContainerModule, diff --git a/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiInjectConstructorArgument.ts b/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiInjectConstructorArgument.ts index f24024e0..216344ae 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiInjectConstructorArgument.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiInjectConstructorArgument.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container, inject, injectable } from 'inversify'; interface Weapon { diff --git a/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiInjectProperty.ts b/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiInjectProperty.ts index 3f4f168b..6fa78dbf 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiInjectProperty.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiInjectProperty.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container, inject, injectable } from 'inversify'; interface Weapon { diff --git a/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiMultiInjectProperty.ts b/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiMultiInjectProperty.ts index ece96194..7c9252a2 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiMultiInjectProperty.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiMultiInjectProperty.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container, injectable, multiInject } from 'inversify'; export interface Weapon { diff --git a/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiNamed.ts b/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiNamed.ts index 2fc712ad..151495f4 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiNamed.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiNamed.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container, inject, injectable, named } from 'inversify'; interface Weapon { diff --git a/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiOptional.ts b/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiOptional.ts index 6f9f5887..e8fb5a27 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiOptional.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiOptional.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container, inject, injectable, optional } from 'inversify'; interface Weapon { diff --git a/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiPostConstruct.ts b/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiPostConstruct.ts index acff2e56..80aa1c10 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiPostConstruct.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiPostConstruct.ts @@ -1,4 +1,5 @@ /* eslint-disable @typescript-eslint/no-magic-numbers */ +// Is-inversify-import-example import { Container, postConstruct } from 'inversify'; // Begin-example diff --git a/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiPreDestroy.ts b/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiPreDestroy.ts index cefbf960..05121648 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiPreDestroy.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiPreDestroy.ts @@ -1,5 +1,6 @@ import { jest } from '@jest/globals'; +// Is-inversify-import-example import { Container, preDestroy } from 'inversify'; // Begin-example diff --git a/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiTagged.ts b/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiTagged.ts index e64047e7..2e05ed00 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiTagged.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiTagged.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container, inject, injectable, tagged } from 'inversify'; interface Weapon { diff --git a/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiUnmanaged.ts b/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiUnmanaged.ts index 026edd21..bdd09919 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiUnmanaged.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/decoratorApiUnmanaged.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container, injectable, unmanaged } from 'inversify'; @injectable() diff --git a/packages/docs/tools/inversify-code-examples/src/examples/dependencyInversion.ts b/packages/docs/tools/inversify-code-examples/src/examples/dependencyInversion.ts index b66daf9d..7b6add20 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/dependencyInversion.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/dependencyInversion.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container, inject, injectable } from 'inversify'; interface Weapon { diff --git a/packages/docs/tools/inversify-code-examples/src/examples/diHierarchy.ts b/packages/docs/tools/inversify-code-examples/src/examples/diHierarchy.ts index 7282e994..50bd7dd2 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/diHierarchy.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/diHierarchy.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container } from 'inversify'; const weaponIdentifier: symbol = Symbol.for('Weapon'); diff --git a/packages/docs/tools/inversify-code-examples/src/examples/gettingStarted.ts b/packages/docs/tools/inversify-code-examples/src/examples/gettingStarted.ts index 3196ac5c..20583a3d 100644 --- a/packages/docs/tools/inversify-code-examples/src/examples/gettingStarted.ts +++ b/packages/docs/tools/inversify-code-examples/src/examples/gettingStarted.ts @@ -1,3 +1,4 @@ +// Is-inversify-import-example import { Container, inject, injectable } from 'inversify'; @injectable() From 69a4281c9f7a62b3456807d5b974468144395dfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Pintos=20L=C3=B3pez?= Date: Sun, 19 Jan 2025 22:26:43 +0100 Subject: [PATCH 2/6] feat(inversify-code-examples): add dependency inversion v7 code example --- .../v7/dependencyInversion.int.spec.ts | 9 +++++ .../src/examples/v7/dependencyInversion.ts | 33 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 packages/docs/tools/inversify-code-examples/src/examples/v7/dependencyInversion.int.spec.ts create mode 100644 packages/docs/tools/inversify-code-examples/src/examples/v7/dependencyInversion.ts diff --git a/packages/docs/tools/inversify-code-examples/src/examples/v7/dependencyInversion.int.spec.ts b/packages/docs/tools/inversify-code-examples/src/examples/v7/dependencyInversion.int.spec.ts new file mode 100644 index 00000000..0939287b --- /dev/null +++ b/packages/docs/tools/inversify-code-examples/src/examples/v7/dependencyInversion.int.spec.ts @@ -0,0 +1,9 @@ +import { describe, expect, it } from '@jest/globals'; + +import { ninja } from './dependencyInversion'; + +describe('dependency inversion', () => { + it('should provide a ninja with a weapon with right damage', () => { + expect(ninja.weapon.damage).toBe(10); + }); +}); diff --git a/packages/docs/tools/inversify-code-examples/src/examples/v7/dependencyInversion.ts b/packages/docs/tools/inversify-code-examples/src/examples/v7/dependencyInversion.ts new file mode 100644 index 00000000..be5dff27 --- /dev/null +++ b/packages/docs/tools/inversify-code-examples/src/examples/v7/dependencyInversion.ts @@ -0,0 +1,33 @@ +// Is-inversify-import-example +import { Container, inject, injectable } from 'inversify7'; + +interface Weapon { + damage: number; +} + +const weaponServiceId: symbol = Symbol.for('WeaponServiceId'); + +@injectable() +class Katana { + public readonly damage: number = 10; +} + +@injectable() +class Ninja { + constructor( + @inject(weaponServiceId) + public readonly weapon: Weapon, + ) {} +} + +const container: Container = new Container(); + +container.bind(Ninja).toSelf(); +container.bind(weaponServiceId).to(Katana); + +const ninja: Ninja = container.get(Ninja); + +console.log(ninja.weapon.damage); // Prints 10 +// End-example + +export { ninja }; From 7a3bcc376b870ec1a5a36fb7497f6052cf6fa6a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Pintos=20L=C3=B3pez?= Date: Mon, 20 Jan 2025 00:37:38 +0100 Subject: [PATCH 3/6] feat(inversify-site): update dependency inversion page --- .../inversify-site/docs/introduction/dependency-inversion.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/docs/services/inversify-site/docs/introduction/dependency-inversion.mdx b/packages/docs/services/inversify-site/docs/introduction/dependency-inversion.mdx index d9c3dfa2..72fe6f5d 100644 --- a/packages/docs/services/inversify-site/docs/introduction/dependency-inversion.mdx +++ b/packages/docs/services/inversify-site/docs/introduction/dependency-inversion.mdx @@ -3,7 +3,7 @@ sidebar_position: 2 title: Dependency inversion --- import CodeBlock from '@theme/CodeBlock'; -import dependencyInversionSource from '@inversifyjs/code-examples/generated/examples/dependencyInversion.ts.txt'; +import dependencyInversionSource from '@inversifyjs/code-examples/generated/examples/v7/dependencyInversion.ts.txt'; # Dependency inversion From a21cf3d5d2ed2fdde869ceec993d98da2d6ccbd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Pintos=20L=C3=B3pez?= Date: Mon, 20 Jan 2025 00:40:22 +0100 Subject: [PATCH 4/6] refactor(inversify-site): update doc links to support multiple docusaurus version --- .../docs/api/binding-syntax.mdx | 8 +- .../docs/api/container-module.mdx | 12 +- .../inversify-site/docs/api/container.mdx | 16 +- .../inversify-site/docs/api/decorator.mdx | 8 +- .../docs/fundamentals/binding.mdx | 4 +- .../docs/fundamentals/inheritance.mdx | 46 +---- .../fundamentals/lifecycle/activation.mdx | 6 +- .../fundamentals/lifecycle/deactivation.mdx | 6 +- .../fundamentals/lifecycle/middleware.mdx | 157 ------------------ 9 files changed, 31 insertions(+), 232 deletions(-) delete mode 100644 packages/docs/services/inversify-site/docs/fundamentals/lifecycle/middleware.mdx diff --git a/packages/docs/services/inversify-site/docs/api/binding-syntax.mdx b/packages/docs/services/inversify-site/docs/api/binding-syntax.mdx index f4f988f4..597865e0 100644 --- a/packages/docs/services/inversify-site/docs/api/binding-syntax.mdx +++ b/packages/docs/services/inversify-site/docs/api/binding-syntax.mdx @@ -15,7 +15,7 @@ import CodeBlock from '@theme/CodeBlock'; # Binding Syntax -Binding syntax is provided as a fluent interface resulting from using the [container API](/docs/api/container#bind) or the [container module API](/docs/api/container-module#bind). +Binding syntax is provided as a fluent interface resulting from using the [container API](./container.mdx#bind) or the [container module API](./container-module.mdx#bind). ## BindToFluentSyntax @@ -133,7 +133,7 @@ Represents a service binding given a service identifier and a service resolution inSingletonScope(): BindWhenOnFluentSyntax; ``` -Sets the binding scope to singleton. Refer to the [docs](/docs/fundamentals/binding#singleton) for more information. +Sets the binding scope to singleton. Refer to the [docs](../fundamentals/binding.mdx#singleton) for more information. ### inTransientScope @@ -141,7 +141,7 @@ Sets the binding scope to singleton. Refer to the [docs](/docs/fundamentals/bind inTransientScope(): BindWhenOnFluentSyntax; ``` -Sets the binding scope to transient. Refer to the [docs](/docs/fundamentals/binding#transient) for more information. +Sets the binding scope to transient. Refer to the [docs](../fundamentals/binding.mdx#transient) for more information. ### inRequestScope @@ -149,7 +149,7 @@ Sets the binding scope to transient. Refer to the [docs](/docs/fundamentals/bind inRequestScope(): BindWhenOnFluentSyntax; ``` -Sets the binding scope to request. Refer to the [docs](/docs/fundamentals/binding#request) for more information. +Sets the binding scope to request. Refer to the [docs](../fundamentals/binding.mdx#request) for more information. ## BindOnFluentSyntax diff --git a/packages/docs/services/inversify-site/docs/api/container-module.mdx b/packages/docs/services/inversify-site/docs/api/container-module.mdx index 15f5ef5e..0a84f664 100644 --- a/packages/docs/services/inversify-site/docs/api/container-module.mdx +++ b/packages/docs/services/inversify-site/docs/api/container-module.mdx @@ -37,7 +37,7 @@ Options to be passed to the load callback. It contains the following properties: bind: (serviceIdentifier: ServiceIdentifier) => BindToFluentSyntax ``` -Refer to the [docs](/docs/api/container#bind) for more information. +Refer to the [docs](./container.mdx#bind) for more information. ### isBound @@ -45,7 +45,7 @@ Refer to the [docs](/docs/api/container#bind) for more information. isBound: (serviceIdentifier: ServiceIdentifier, options?: IsBoundOptions) => boolean ``` -Refer to the [docs](/docs/api/container#isbound) for more information. +Refer to the [docs](./container.mdx#isbound) for more information. ### onActivation @@ -53,7 +53,7 @@ Refer to the [docs](/docs/api/container#isbound) for more information. onActivation: (serviceIdentifier: ServiceIdentifier, activation: BindingActivation) => void ``` -Refer to the [docs](/docs/api/container#onactivation) for more information. +Refer to the [docs](./container.mdx#onactivation) for more information. ### onDeactivation @@ -61,7 +61,7 @@ Refer to the [docs](/docs/api/container#onactivation) for more information. onDeactivation: (serviceIdentifier: ServiceIdentifier, deactivation: BindingDeactivation) => void ``` -Refer to the [docs](/docs/api/container#ondeactivation) for more information. +Refer to the [docs](./container.mdx#ondeactivation) for more information. ### unbind @@ -69,12 +69,12 @@ Refer to the [docs](/docs/api/container#ondeactivation) for more information. unbind: (serviceIdentifier: ServiceIdentifier) => Promise ``` -Refer to the [docs](/docs/api/container#unbind) for more information. +Refer to the [docs](./container.mdx#unbind) for more information. ## Example: binding services through ContainerModule API When a container module is loaded into a Container, the load callback is invoked. This is the opportunity for the container module to register bindings and handlers. -When a container module is unloaded from a Container, the bindings added by that container will be removed, and the [deactivation process](/docs/fundamentals/lifecycle/deactivation) will occur for each of them. Container deactivation and [activation handlers](/docs/fundamentals/lifecycle/activation) will also be removed. +When a container module is unloaded from a Container, the bindings added by that container will be removed, and the [deactivation process](../fundamentals/lifecycle/deactivation.mdx) will occur for each of them. Container deactivation and [activation handlers](../fundamentals/lifecycle/activation.mdx) will also be removed. {containerModuleApiExampleSource} diff --git a/packages/docs/services/inversify-site/docs/api/container.mdx b/packages/docs/services/inversify-site/docs/api/container.mdx index 9220ed99..f7c6d011 100644 --- a/packages/docs/services/inversify-site/docs/api/container.mdx +++ b/packages/docs/services/inversify-site/docs/api/container.mdx @@ -33,7 +33,7 @@ Options can be changed after construction and will be shared by child containers parent?: Container | undefined; ``` -The parent container, if any. Refer to the [container hierarchy docs](/docs/fundamentals/di-hierarchy) for more information. +The parent container, if any. Refer to the [container hierarchy docs](../fundamentals/di-hierarchy.mdx) for more information. ### defaultScope @@ -120,7 +120,7 @@ You can use the `isCurrentBound` method to check if there are registered binding load(...modules: ContainerModule[]): Promise; ``` -Calls the registration method of each module. See [ContainerModule API docs](/docs/api/container-module). +Calls the registration method of each module. See [ContainerModule API docs](./container-module.mdx). ## onActivation @@ -148,7 +148,7 @@ Adds a deactivation handler for a service identifier. restore(): void; ``` -Restore container state to last snapshot. Refer to the [docs](/docs/fundamentals/snapshot) for more information. +Restore container state to last snapshot. Refer to the [docs](../fundamentals/snapshot.mdx) for more information. ## snapshot @@ -156,7 +156,7 @@ Restore container state to last snapshot. Refer to the [docs](/docs/fundamentals snapshot(): void; ``` -Save the state of the container to be later restored with the restore method. Refer to the [docs](/docs/fundamentals/snapshot) for more information. +Save the state of the container to be later restored with the restore method. Refer to the [docs](../fundamentals/snapshot.mdx) for more information. ## unbind @@ -164,7 +164,7 @@ Save the state of the container to be later restored with the restore method. Re unbind(serviceIdentifier: ServiceIdentifier): Promise; ``` -Remove all bindings binded in this container to the service identifier. This will result in the [deactivation process](/docs/fundamentals/lifecycle/deactivation). +Remove all bindings binded in this container to the service identifier. This will result in the [deactivation process](../fundamentals/lifecycle/deactivation.mdx). ## unbindAll @@ -172,7 +172,7 @@ Remove all bindings binded in this container to the service identifier. This wil unbindAll(): Promise; ``` -Remove all bindings binded in this container. This will result in the [deactivation process](/docs/fundamentals/lifecycle/deactivation). +Remove all bindings binded in this container. This will result in the [deactivation process](../fundamentals/lifecycle/deactivation.mdx). ## unload @@ -180,5 +180,5 @@ Remove all bindings binded in this container. This will result in the [deactiva unload(...modules: ContainerModule[]): Promise; ``` -Removes bindings and handlers added by the modules. This will result in the [deactivation process](/docs/fundamentals/lifecycle/deactivation). -See [ContainerModule API docs](/docs/api/container-module). +Removes bindings and handlers added by the modules. This will result in the [deactivation process](../fundamentals/lifecycle/deactivation.mdx). +See [ContainerModule API docs](./container-module.mdx). diff --git a/packages/docs/services/inversify-site/docs/api/decorator.mdx b/packages/docs/services/inversify-site/docs/api/decorator.mdx index 241c25ba..2c6a689c 100644 --- a/packages/docs/services/inversify-site/docs/api/decorator.mdx +++ b/packages/docs/services/inversify-site/docs/api/decorator.mdx @@ -87,7 +87,7 @@ This time, no class metadata is emitted even if the `emitDecoratorMetadata` Type Decorator used to establish a relation between a constructor argument or a class property and a service ID. -When resolving an instance of the class, the target constructor argument or property will be resolved in the same way [container.get](/docs/api/container#get) behaves. +When resolving an instance of the class, the target constructor argument or property will be resolved in the same way [container.get](./container.mdx#get) behaves. ### Example: decorating a class constructor argument @@ -101,7 +101,7 @@ When resolving an instance of the class, the target constructor argument or prop Decorator used to establish a relation between a constructor argument or a class property and a service ID. -When resolving an instance of the class, the target constructor argument or property will be resolved in the same way [container.getAll](/docs/api/container#getall) behaves. +When resolving an instance of the class, the target constructor argument or property will be resolved in the same way [container.getAll](./container.mdx#getall) behaves. ### Example: decorating a property @@ -121,13 +121,13 @@ Decorator used to establish that a target constructor argument or property is op ## postConstruct -Decorator used to establish an activation handler for the target class. Refer to the [docs](/docs/fundamentals/lifecycle/activation) for more information. +Decorator used to establish an activation handler for the target class. Refer to the [docs](../fundamentals/lifecycle/activation.mdx) for more information. {decoratorApiPostConstructSource} ## preDestroy -Decorator used to establish a deactivation handler for the target class. Refer to the [docs](/docs/fundamentals/lifecycle/deactivation) for more information. +Decorator used to establish a deactivation handler for the target class. Refer to the [docs](../fundamentals/lifecycle/deactivation.mdx) for more information. {decoratorApiPreDestroySource} diff --git a/packages/docs/services/inversify-site/docs/fundamentals/binding.mdx b/packages/docs/services/inversify-site/docs/fundamentals/binding.mdx index 901e1aa0..ce1311be 100644 --- a/packages/docs/services/inversify-site/docs/fundamentals/binding.mdx +++ b/packages/docs/services/inversify-site/docs/fundamentals/binding.mdx @@ -48,8 +48,8 @@ When the service is resolved, a new resolved value will be used each time. ### Constraint -Specifies whether the binding is used to provide a resolved value for the given service identifier. Refer to the [API docs](/docs/api/binding-syntax#bindingwhensyntax) for more information. +Specifies whether the binding is used to provide a resolved value for the given service identifier. Refer to the [API docs](../api/binding-syntax.mdx#bindwhenfluentsyntax) for more information. ### Lifecycle handlers -Handlers that are called after a resolved value is provided or a singleton-scoped binding is deactivated. Refer to the [API docs](/docs/api/binding-syntax#bindingonsyntax) for more information. +Handlers that are called after a resolved value is provided or a singleton-scoped binding is deactivated. Refer to the [API docs](../api/binding-syntax.mdx#bindonfluentsyntax) for more information. diff --git a/packages/docs/services/inversify-site/docs/fundamentals/inheritance.mdx b/packages/docs/services/inversify-site/docs/fundamentals/inheritance.mdx index 8a2f5b86..a17afe59 100644 --- a/packages/docs/services/inversify-site/docs/fundamentals/inheritance.mdx +++ b/packages/docs/services/inversify-site/docs/fundamentals/inheritance.mdx @@ -4,49 +4,5 @@ title: Inheritance --- # Inheritance -Inheritance can be achieved as long as constructor parameters are properly decorated. There are two ways to ensure this: +Inheritance can be achieved relying on the `@injectFromBase` decorator. This decorator allows you to inject dependencies from the base class constructor. -- The number of decorated constructor arguments in a derived class is greater than or equal to the number of constructor arguments in its base class. -- The [skipBaseClassChecks](/docs/api/container#skipbaseclasschecks) option is enabled. - -## Example of incorrect inheritance injection - -```ts -@injectable() -class Warrior { - public rank: string; - constructor(rank: string) { // args count = 1 - this.rank = rank; - } -} - -@injectable() -class SamuraiMaster extends Warrior { - constructor() { // args count = 0 - super("master"); - } -} -``` - -When trying to get a `SamuraiMaster`, the container throws an error indicating that the constructor parameters are not properly decorated. - -## Using the @unmanaged decorator - -The [unmanaged](/docs/api/decorator#unmanaged) decorator tells Inversify that a base type constructor parameter should not be managed. This is often the case when dealing with inheritance hierarchies where only leaf types are injected. - -```ts -@injectable() -class Warrior { - public rank: string; - constructor(@unmanaged() rank: string) { // args count = 0, unmanaged args are not included - this.rank = rank; - } -} - -@injectable() -class SamuraiMaster extends Warrior { - constructor() { // args count = 0 - super("master"); - } -} -``` diff --git a/packages/docs/services/inversify-site/docs/fundamentals/lifecycle/activation.mdx b/packages/docs/services/inversify-site/docs/fundamentals/lifecycle/activation.mdx index 1594b3da..3b5e7176 100644 --- a/packages/docs/services/inversify-site/docs/fundamentals/lifecycle/activation.mdx +++ b/packages/docs/services/inversify-site/docs/fundamentals/lifecycle/activation.mdx @@ -11,9 +11,9 @@ Whenever a service is resolved, the activation event is dispatched. An activatio There are multiple ways to provide an activation handler -- Adding the handler to the [container](/docs/api/container#onactivation). -- Adding the handler to the [binding](/docs/api/binding-syntax#onactivation). -- Adding the handler to the class through the [postConstruct decorator](/docs/api/decorator#postconstruct). +- Adding the handler to the [container](../../api/container.mdx#onactivation). +- Adding the handler to the [binding](../../api/binding-syntax.mdx#onactivation). +- Adding the handler to the class through the [postConstruct decorator](../../api/decorator.mdx#postconstruct). When multiple activation handlers are binded to a service identifier, the `postConstruct` handler is called before any others. After that, the binding handler is called. Then, container handlers are called, starting at the root container and descending the descendant containers stopping at the container with the binding. diff --git a/packages/docs/services/inversify-site/docs/fundamentals/lifecycle/deactivation.mdx b/packages/docs/services/inversify-site/docs/fundamentals/lifecycle/deactivation.mdx index 1a225cf0..87d0bf20 100644 --- a/packages/docs/services/inversify-site/docs/fundamentals/lifecycle/deactivation.mdx +++ b/packages/docs/services/inversify-site/docs/fundamentals/lifecycle/deactivation.mdx @@ -11,8 +11,8 @@ Whenever a singleton scoped service is unbound, the deactivation event is dispat It's possible to add a deactivation handler in multiple ways -- Adding the handler to the [container](/docs/api/container#ondeactivation). -- Adding the handler to a [binding](/docs/api/binding-syntax#ondeactivation). -- Adding the handler to the class through the [preDestroy decorator](/docs/api/decorator#predestroy). +- Adding the handler to the [container](../../api/container.mdx#ondeactivation). +- Adding the handler to a [binding](../../api/binding-syntax.mdx#ondeactivation). +- Adding the handler to the class through the [preDestroy decorator](../../api/decorator.mdx#predestroy). Handlers added to the container are the first ones to be resolved. Any handler added to a child container is called before the ones added to their parent. Relevant bindings from the container are called next and finally the `preDestroy` method is called. In the example above, relevant bindings are those bindings bound to the unbinded "Destroyable" service identifier. diff --git a/packages/docs/services/inversify-site/docs/fundamentals/lifecycle/middleware.mdx b/packages/docs/services/inversify-site/docs/fundamentals/lifecycle/middleware.mdx deleted file mode 100644 index 8891a393..00000000 --- a/packages/docs/services/inversify-site/docs/fundamentals/lifecycle/middleware.mdx +++ /dev/null @@ -1,157 +0,0 @@ ---- -sidebar_position: 3 -title: Middleware ---- -# Middleware - -:::warning - -Middleware docs are included for historical reasons. They are likely to be remove in favor of more appropiate features. - -::: - -Middlewares can be added to a container in order to intercept service resolution requests: - -## Basic middleware - -```ts -import { interfaces, Container } from "inversify"; - -function logger(planAndResolve: interfaces.Next): interfaces.Next { - return (args: interfaces.NextArgs) => { - let start = new Date().getTime(); - let result = planAndResolve(args); - let end = new Date().getTime(); - console.log(`wooooo ${end - start}`); - return result; - }; -} - -let container = new Container(); -container.applyMiddleware(logger); -``` - -## Multiple middleware functions - -When multiple middleware functions are applied: - -```ts -container.applyMiddleware(middleware1, middleware2); -``` - -The middleware will be invoked from right to left. -This means that `middleware2` is invoked before `middleware1`. - -## Context interceptor - -In some cases you may want to intercept the resolution plan. - -The default `contextInterceptor` is passed to the middleware as an property of `args`. - -```ts -function middleware1(planAndResolve: interfaces.Next): interfaces.Next { - return (args: interfaces.NextArgs) => { - // args.nextContextInterceptor - // ... - }; -} -``` - -You can extend the default `contextInterceptor` using a function: - -```ts -function middleware1(planAndResolve: interfaces.Next): interfaces.Next { - return (args: interfaces.NextArgs) => { - let nextContextInterceptor = args.contextInterceptor; - args.contextInterceptor = (context: interfaces.Context) => { - console.log(context); - return nextContextInterceptor(context); - }; - return planAndResolve(args); - }; -} -``` - -## Custom metadata reader - -:::danger - -It is not recommended to create your own custom -metadata reader. We have included this feature to allow library / framework creators -to have a higher level of customization but the average user should not use a custom -metadata reader. In general, a custom metadata reader should only be used when -developing a framework in order to provide users with an annotation APIs -less explicit than the default annotation API. - -If you are developing a framework or library and you create a custom metadata reader, -Please remember to provide your framework with support for an alternative for all the -decorators in the default API: `@injectable`, `@inject`, `@multiInject`, `@tagged`, -`@named`, `@optional`, `@postConstruct`, `@preDestroy` `@targetName` & `@unmanaged`. - -::: - -Middleware allows you to intercept a plan and resolve it but you are not allowed to change the way the annotation phase behaves. - -There is a second extension point that allows you to decide what kind of annotation -system you would like to use. The default annotation system is powered by decorators and -reflect-metadata: - -```ts -@injectable() -class Ninja implements Ninja { - - private _katana: Katana; - private _shuriken: Shuriken; - - constructor( - @inject("Katana") katana: Katana, - @inject("Shuriken") shuriken: Shuriken - ) { - this._katana = katana; - this._shuriken = shuriken; - } - - public fight() { return this._katana.hit(); }; - public sneak() { return this._shuriken.throw(); }; - -} -``` - -You can use a custom metadata reader to implement a custom annotation system. - -For example, you could implement an annotation system based on static properties: - -```ts -class Ninja implements Ninja { - - public static constructorInjections = [ - "Katana", "Shuriken" - ]; - - private _katana: Katana; - private _shuriken: Shuriken; - - constructor( - katana: Katana, - shuriken: Shuriken - ) { - this._katana = katana; - this._shuriken = shuriken; - } - - public fight() { return this._katana.hit(); }; - public sneak() { return this._shuriken.throw(); }; - -} -``` - -A custom metadata reader must implement the `interfaces.MetadataReader` interface. - -A full example [can be found in our unit tests](https://github.com/inversify/InversifyJS/blob/master/test/features/metadata_reader.test.ts). - -Once you have a custom metadata reader you will be ready to apply it: - -```ts -let container = new Container(); -container.applyCustomMetadataReader(new StaticPropsMetadataReader()); -``` From 300aa3bc7d6cd046415bfec0ac085150dd3e4839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Pintos=20L=C3=B3pez?= Date: Mon, 20 Jan 2025 00:53:12 +0100 Subject: [PATCH 5/6] refactor(inversify-site): update doc links to support multiple docusaurus version --- .../version-6.x/api/binding-syntax.mdx | 8 ++++---- .../version-6.x/api/container-module.mdx | 16 +++++++-------- .../version-6.x/api/container.mdx | 20 +++++++++---------- .../version-6.x/api/decorator.mdx | 8 ++++---- .../version-6.x/fundamentals/binding.mdx | 4 ++-- .../version-6.x/fundamentals/inheritance.mdx | 4 ++-- .../fundamentals/lifecycle/activation.mdx | 6 +++--- .../fundamentals/lifecycle/deactivation.mdx | 6 +++--- 8 files changed, 36 insertions(+), 36 deletions(-) diff --git a/packages/docs/services/inversify-site/versioned_docs/version-6.x/api/binding-syntax.mdx b/packages/docs/services/inversify-site/versioned_docs/version-6.x/api/binding-syntax.mdx index abeccf6c..f3c423c1 100644 --- a/packages/docs/services/inversify-site/versioned_docs/version-6.x/api/binding-syntax.mdx +++ b/packages/docs/services/inversify-site/versioned_docs/version-6.x/api/binding-syntax.mdx @@ -18,7 +18,7 @@ import CodeBlock from '@theme/CodeBlock'; # Binding Syntax -Binding syntax is provided as a fluent interface resulting from using the [container API](/docs/api/container#bind) or the [container module API](/docs/api/container-module#bind). +Binding syntax is provided as a fluent interface resulting from using the [container API](./container.mdx#bind) or the [container module API](./container-module.mdx#bind). ## BindingToSyntax @@ -166,7 +166,7 @@ Represents a service binding given a service identifier and a service resolution inSingletonScope(): BindingWhenOnSyntax; ``` -Sets the binding scope to singleton. Refer to the [docs](/docs/fundamentals/binding#singleton) for more information. +Sets the binding scope to singleton. Refer to the [docs](../fundamentals/binding.mdx#singleton) for more information. ### inTransientScope @@ -174,7 +174,7 @@ Sets the binding scope to singleton. Refer to the [docs](/docs/fundamentals/bind inTransientScope(): BindingWhenOnSyntax; ``` -Sets the binding scope to transient. Refer to the [docs](/docs/fundamentals/binding#transient) for more information. +Sets the binding scope to transient. Refer to the [docs](../fundamentals/binding.mdx#transient) for more information. ### inRequestScope @@ -182,7 +182,7 @@ Sets the binding scope to transient. Refer to the [docs](/docs/fundamentals/bind inRequestScope(): BindingWhenOnSyntax; ``` -Sets the binding scope to request. Refer to the [docs](/docs/fundamentals/binding#request) for more information. +Sets the binding scope to request. Refer to the [docs](../fundamentals/binding.mdx#request) for more information. ## BindingOnSyntax diff --git a/packages/docs/services/inversify-site/versioned_docs/version-6.x/api/container-module.mdx b/packages/docs/services/inversify-site/versioned_docs/version-6.x/api/container-module.mdx index ebcb553a..b1aba2b6 100644 --- a/packages/docs/services/inversify-site/versioned_docs/version-6.x/api/container-module.mdx +++ b/packages/docs/services/inversify-site/versioned_docs/version-6.x/api/container-module.mdx @@ -23,7 +23,7 @@ The constructor argument for `ContainerModule` is a registration callback with f bind: interfaces.Bind ``` -Refer to the [docs](/docs/api/container#bind) for more information. +Refer to the [docs](./container.mdx#bind) for more information. ### unbind @@ -31,7 +31,7 @@ Refer to the [docs](/docs/api/container#bind) for more information. unbind: interfaces.Unbind ``` -Refer to the [docs](/docs/api/container#unbind) for more information. +Refer to the [docs](./container.mdx#unbind) for more information. ### isBound @@ -39,7 +39,7 @@ Refer to the [docs](/docs/api/container#unbind) for more information. isBound: interfaces.IsBound ``` -Refer to the [docs](/docs/api/container#isbound) for more information. +Refer to the [docs](./container.mdx#isbound) for more information. ### rebind @@ -47,7 +47,7 @@ Refer to the [docs](/docs/api/container#isbound) for more information. rebind: interfaces.Rebind ``` -Refer to the [docs](/docs/api/container#rebind) for more information. +Refer to the [docs](./container.mdx#rebind) for more information. ### unbindAsync @@ -55,7 +55,7 @@ Refer to the [docs](/docs/api/container#rebind) for more information. unbindAsync: interfaces.UnbindAsync ``` -Refer to the [docs](/docs/api/container#unbindasync) for more information. +Refer to the [docs](./container.mdx#unbindasync) for more information. ### onActivation @@ -63,7 +63,7 @@ Refer to the [docs](/docs/api/container#unbindasync) for more information. onActivation: interfaces.Container['onActivation'] ``` -Refer to the [docs](/docs/api/container#onactivation) for more information. +Refer to the [docs](./container.mdx#onactivation) for more information. ### onDeactivation @@ -71,12 +71,12 @@ Refer to the [docs](/docs/api/container#onactivation) for more information. onDeactivation: interfaces.Container['onDeactivation'] ``` -Refer to the [docs](/docs/api/container#ondeactivation) for more information. +Refer to the [docs](./container.mdx#ondeactivation) for more information. ## Example: binding services through ContainerModule API When a container module is loaded into a Container, the registration callback is invoked. This is the opportunity for the container module to register bindings and handlers. Use the Container `load` method for `ContainerModule` instances and the Container `loadAsync` method for `AsyncContainerModule` instances. -When a container module is unloaded from a Container, the bindings added by that container will be removed, and the [deactivation process](/docs/fundamentals/lifecycle/deactivation) will occur for each of them. Container deactivation and [activation handlers](/docs/fundamentals/lifecycle/activation) will also be removed. Use the `unloadAsync` method to unload when there will be an async deactivation handler or async [preDestroy](/docs/api/decorator#predestroy). +When a container module is unloaded from a Container, the bindings added by that container will be removed, and the [deactivation process](../fundamentals/lifecycle/deactivation.mdx) will occur for each of them. Container deactivation and [activation handlers](../fundamentals/lifecycle/activation.mdx) will also be removed. Use the `unloadAsync` method to unload when there will be an async deactivation handler or async [preDestroy](./decorator.mdx#predestroy). {containerModuleApiExampleSource} diff --git a/packages/docs/services/inversify-site/versioned_docs/version-6.x/api/container.mdx b/packages/docs/services/inversify-site/versioned_docs/version-6.x/api/container.mdx index f1d452a5..002c1244 100644 --- a/packages/docs/services/inversify-site/versioned_docs/version-6.x/api/container.mdx +++ b/packages/docs/services/inversify-site/versioned_docs/version-6.x/api/container.mdx @@ -89,7 +89,7 @@ Creates a new Container containing the bindings ( cloned bindings ) of two or mo applyCustomMetadataReader(metadataReader: interfaces.MetadataReader): void; ``` -Sets a custom metadata reader. See [middleware](/docs/fundamentals/lifecycle/middleware). +Sets a custom metadata reader. See [middleware](../fundamentals/lifecycle/middleware.mdx). ## applyMiddleware @@ -97,7 +97,7 @@ Sets a custom metadata reader. See [middleware](/docs/fundamentals/lifecycle/mid applyMiddleware(...middleware: interfaces.Middleware[]): void; ``` -An advanced feature that can be used for cross cutting concerns. See [middleware](/docs/fundamentals/lifecycle/middleware). +An advanced feature that can be used for cross cutting concerns. See [middleware](../fundamentals/lifecycle/middleware.mdx). ## bind @@ -113,7 +113,7 @@ Sets a new binding. createChild(containerOptions?: interfaces.ContainerOptions): Container; ``` -Create a [container hierarchy](/docs/fundamentals/di-hierarchy). Parent `ContainerOptions` are provided by default. +Create a [container hierarchy](../fundamentals/di-hierarchy.mdx). Parent `ContainerOptions` are provided by default. ## get @@ -290,7 +290,7 @@ You can use the `isBoundTagged` method to check if there are registered bindings load(...modules: interfaces.ContainerModule[]): void; ``` -Calls the registration method of each module. See [ContainerModule API docs](/docs/api/container-module) +Calls the registration method of each module. See [ContainerModule API docs](./container-module.mdx) ## loadAsync @@ -356,7 +356,7 @@ Adds a deactivation handler for a service identifier. restore(): void; ``` -Restore container state to last snapshot. Refer to the [docs](/docs/fundamentals/snapshot) for more information. +Restore container state to last snapshot. Refer to the [docs](../fundamentals/snapshot.mdx) for more information. ## snapshot @@ -364,7 +364,7 @@ Restore container state to last snapshot. Refer to the [docs](/docs/fundamentals snapshot(): void; ``` -Save the state of the container to be later restored with the restore method. Refer to the [docs](/docs/fundamentals/snapshot) for more information. +Save the state of the container to be later restored with the restore method. Refer to the [docs](../fundamentals/snapshot.mdx) for more information. ## tryGet @@ -468,7 +468,7 @@ Same as `container.getAllTaggedAsync`, but returns `Promise<[]>` in the event no unbind(serviceIdentifier: interfaces.ServiceIdentifier): void; ``` -Remove all bindings binded in this container to the service identifier. This will result in the [deactivation process](/docs/fundamentals/lifecycle/deactivation). +Remove all bindings binded in this container to the service identifier. This will result in the [deactivation process](../fundamentals/lifecycle/deactivation.mdx). ## unbindAsync @@ -484,7 +484,7 @@ This is the asynchronous version of unbind. If any deactivation realated to this unbindAll(): void; ``` -Remove all bindings binded in this container. This will result in the [deactivation process](/docs/fundamentals/lifecycle/deactivation). +Remove all bindings binded in this container. This will result in the [deactivation process](../fundamentals/lifecycle/deactivation.mdx). ## unbindAllAsync @@ -500,8 +500,8 @@ This is the asynchronous version of unbindAll. If any of the container's deactiv unload(...modules: interfaces.ContainerModuleBase[]): void; ``` -Removes bindings and handlers added by the modules. This will result in the [deactivation process](/docs/fundamentals/lifecycle/deactivation). -See [ContainerModule API docs](/docs/api/container-module). +Removes bindings and handlers added by the modules. This will result in the [deactivation process](../fundamentals/lifecycle/deactivation.mdx). +See [ContainerModule API docs](./container-module.mdx). ## unloadAsync diff --git a/packages/docs/services/inversify-site/versioned_docs/version-6.x/api/decorator.mdx b/packages/docs/services/inversify-site/versioned_docs/version-6.x/api/decorator.mdx index 9eeefe72..c4458a1e 100644 --- a/packages/docs/services/inversify-site/versioned_docs/version-6.x/api/decorator.mdx +++ b/packages/docs/services/inversify-site/versioned_docs/version-6.x/api/decorator.mdx @@ -90,7 +90,7 @@ This time, no class metadata is emitted even if the `emitDecoratorMetadata` Type Decorator used to establish a relation between a constructor argument or a class property and a service ID. -When resolving an instance of the class, the target constructor argument or property will be resolved in the same way [container.get](/docs/api/container#get) behaves. +When resolving an instance of the class, the target constructor argument or property will be resolved in the same way [container.get](./container.mdx#get) behaves. ### Example: decorating a class constructor argument @@ -104,7 +104,7 @@ When resolving an instance of the class, the target constructor argument or prop Decorator used to establish a relation between a constructor argument or a class property and a service ID. -When resolving an instance of the class, the target constructor argument or property will be resolved in the same way [container.getAll](/docs/api/container#getall) behaves with the `enforceBindingConstraints` flag enabled. +When resolving an instance of the class, the target constructor argument or property will be resolved in the same way [container.getAll](./container.mdx#getall) behaves with the `enforceBindingConstraints` flag enabled. ### Example: decorating a property @@ -124,13 +124,13 @@ Decorator used to establish that a target constructor argument or property is op ## postConstruct -Decorator used to establish an activation handler for the target class. Refer to the [docs](/docs/fundamentals/lifecycle/activation) for more information. +Decorator used to establish an activation handler for the target class. Refer to the [docs](../fundamentals/lifecycle/activation.mdx) for more information. {decoratorApiPostConstructSource} ## preDestroy -Decorator used to establish a deactivation handler for the target class. Refer to the [docs](/docs/fundamentals/lifecycle/deactivation) for more information. +Decorator used to establish a deactivation handler for the target class. Refer to the [docs](../fundamentals/lifecycle/deactivation.mdx) for more information. {decoratorApiPreDestroySource} diff --git a/packages/docs/services/inversify-site/versioned_docs/version-6.x/fundamentals/binding.mdx b/packages/docs/services/inversify-site/versioned_docs/version-6.x/fundamentals/binding.mdx index 8227fb50..ada40038 100644 --- a/packages/docs/services/inversify-site/versioned_docs/version-6.x/fundamentals/binding.mdx +++ b/packages/docs/services/inversify-site/versioned_docs/version-6.x/fundamentals/binding.mdx @@ -48,8 +48,8 @@ When the service is resolved, a new resolved value will be used each time. ### Constraint -Specifies whether the binding is used to provide a resolved value for the given service identifier. Refer to the [API docs](/docs/api/binding-syntax#bindingwhensyntax) for more information. +Specifies whether the binding is used to provide a resolved value for the given service identifier. Refer to the [API docs](../api/binding-syntax.mdx#bindingwhensyntax) for more information. ### Lifecycle handlers -Handlers that are called after a resolved value is provided or a singleton-scoped binding is deactivated. Refer to the [API docs](/docs/api/binding-syntax#bindingonsyntax) for more information. +Handlers that are called after a resolved value is provided or a singleton-scoped binding is deactivated. Refer to the [API docs](../api/binding-syntax.mdx#bindingonsyntax) for more information. diff --git a/packages/docs/services/inversify-site/versioned_docs/version-6.x/fundamentals/inheritance.mdx b/packages/docs/services/inversify-site/versioned_docs/version-6.x/fundamentals/inheritance.mdx index 8a2f5b86..8035476e 100644 --- a/packages/docs/services/inversify-site/versioned_docs/version-6.x/fundamentals/inheritance.mdx +++ b/packages/docs/services/inversify-site/versioned_docs/version-6.x/fundamentals/inheritance.mdx @@ -7,7 +7,7 @@ title: Inheritance Inheritance can be achieved as long as constructor parameters are properly decorated. There are two ways to ensure this: - The number of decorated constructor arguments in a derived class is greater than or equal to the number of constructor arguments in its base class. -- The [skipBaseClassChecks](/docs/api/container#skipbaseclasschecks) option is enabled. +- The [skipBaseClassChecks](../api/container.mdx#skipbaseclasschecks) option is enabled. ## Example of incorrect inheritance injection @@ -32,7 +32,7 @@ When trying to get a `SamuraiMaster`, the container throws an error indicating t ## Using the @unmanaged decorator -The [unmanaged](/docs/api/decorator#unmanaged) decorator tells Inversify that a base type constructor parameter should not be managed. This is often the case when dealing with inheritance hierarchies where only leaf types are injected. +The [unmanaged](../api/decorator.mdx#unmanaged) decorator tells Inversify that a base type constructor parameter should not be managed. This is often the case when dealing with inheritance hierarchies where only leaf types are injected. ```ts @injectable() diff --git a/packages/docs/services/inversify-site/versioned_docs/version-6.x/fundamentals/lifecycle/activation.mdx b/packages/docs/services/inversify-site/versioned_docs/version-6.x/fundamentals/lifecycle/activation.mdx index 1594b3da..3b5e7176 100644 --- a/packages/docs/services/inversify-site/versioned_docs/version-6.x/fundamentals/lifecycle/activation.mdx +++ b/packages/docs/services/inversify-site/versioned_docs/version-6.x/fundamentals/lifecycle/activation.mdx @@ -11,9 +11,9 @@ Whenever a service is resolved, the activation event is dispatched. An activatio There are multiple ways to provide an activation handler -- Adding the handler to the [container](/docs/api/container#onactivation). -- Adding the handler to the [binding](/docs/api/binding-syntax#onactivation). -- Adding the handler to the class through the [postConstruct decorator](/docs/api/decorator#postconstruct). +- Adding the handler to the [container](../../api/container.mdx#onactivation). +- Adding the handler to the [binding](../../api/binding-syntax.mdx#onactivation). +- Adding the handler to the class through the [postConstruct decorator](../../api/decorator.mdx#postconstruct). When multiple activation handlers are binded to a service identifier, the `postConstruct` handler is called before any others. After that, the binding handler is called. Then, container handlers are called, starting at the root container and descending the descendant containers stopping at the container with the binding. diff --git a/packages/docs/services/inversify-site/versioned_docs/version-6.x/fundamentals/lifecycle/deactivation.mdx b/packages/docs/services/inversify-site/versioned_docs/version-6.x/fundamentals/lifecycle/deactivation.mdx index 1a225cf0..87d0bf20 100644 --- a/packages/docs/services/inversify-site/versioned_docs/version-6.x/fundamentals/lifecycle/deactivation.mdx +++ b/packages/docs/services/inversify-site/versioned_docs/version-6.x/fundamentals/lifecycle/deactivation.mdx @@ -11,8 +11,8 @@ Whenever a singleton scoped service is unbound, the deactivation event is dispat It's possible to add a deactivation handler in multiple ways -- Adding the handler to the [container](/docs/api/container#ondeactivation). -- Adding the handler to a [binding](/docs/api/binding-syntax#ondeactivation). -- Adding the handler to the class through the [preDestroy decorator](/docs/api/decorator#predestroy). +- Adding the handler to the [container](../../api/container.mdx#ondeactivation). +- Adding the handler to a [binding](../../api/binding-syntax.mdx#ondeactivation). +- Adding the handler to the class through the [preDestroy decorator](../../api/decorator.mdx#predestroy). Handlers added to the container are the first ones to be resolved. Any handler added to a child container is called before the ones added to their parent. Relevant bindings from the container are called next and finally the `preDestroy` method is called. In the example above, relevant bindings are those bindings bound to the unbinded "Destroyable" service identifier. From 2d3e53e099cf460086ab65747ac0bee498e2c022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Pintos=20L=C3=B3pez?= Date: Mon, 20 Jan 2025 00:53:43 +0100 Subject: [PATCH 6/6] chore: update turbo docs site build task with versioned inputs --- turbo.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/turbo.json b/turbo.json index c42bc676..93cd84bd 100644 --- a/turbo.json +++ b/turbo.json @@ -13,7 +13,9 @@ "docs/**", "src/**/*.{cts,mts,ts}", "docusaurus.config.ts", - "sidebars.ts" + "sidebars.ts", + "versioned_docs/**", + "versioned_sidebars/**" ], "outputs": ["build/**"] },