ReadonlyappReadonlydynamicReadonlyimportedReadonlymiddlewaresReadonlymoduleReadonlyoptionsStatic ReadonlyAPP_The identifier of this Module.
It'll be true after the dispose method has been invoked.
The IMiddlewaresManager of this Module.
The IDynamicModuleDefinition of this Module.
It first invokes the reset method and then permanentely destroys the module's container.
Note: If other modules have imported this module, they'll not be able anymore to
resolve dependencies from it which will cause errors to be thrown!
Make sure to use dispose carefully as it is an irreversible action.
Can be used to retrieve a provider from the module container.
The ProviderToken.
OptionalisOptional: IsOptionalWhen set to false (default) an exception will be thrown when the supplied ProviderToken isn't bound.
OptionalasList: AsListSet to true if you need to retrieve all the bound identifiers of the supplied ProviderToken. (defaults to false)
Can be used to retrieve many providers from the module container at once.
Either one or more ProviderToken.
Tuple containing the providers.
// When ProviderTokens are supplied, TS auto-inference works as expected.
// `car` will infer the `Car` type, `engine` the `Engine` type and `dashboard` the `Dashboard` type.
const [car, engine, dashboard, wheels] = Module.getMany(
Car,
Engine,
{ provider: Dashboard, isOptional: true },
{ provider: Wheel, asList: true },
);
// When auto-inference is not possible, you can manually cast the types.
const [configService, userService] = Module.getMany('CONFIG_SERVICE', UserService) as [ConfigService, UserService];
// Now the `configService` is of type `ConfigService` and the `userService` is of type `UserService`.
Can be used to check if this Module has a specific provider bound to its container.
The Provider to lookup for.
Either the ModuleIdentifier or the IProviderModule itself.
Either the ProviderToken or the ProviderIdentifier itself.
Can be used to check if this Module has a specific module imported into it.
Either the ModuleIdentifier or the IProviderModule itself.
Can be used to completely reset a module.
It means that all bound providers will be removed from the container and
all definitions cleared, leaving it as a pristine module ready to be
updated with new definitions.
Note: This is not the same as the dispose method!
Returns the IProviderModule.id.
StaticblueprintCan be used when you don't want to initialize a ProviderModule eagerly as each ProviderModule has its own container
initialized as soon as you do ProviderModule.create({...}).
The ProviderModuleBlueprint allows you to just define a blueprint of a ProviderModule,
you can then decide to either instantiate it or import as it is into different modules (or blueprints).
Note: As soon as you import a blueprint into a module, it'll be automatically transformed into a IProviderModule instance!
Also keep in mind that editing the blueprint after it has been consumed by a module will not propagate the changes to the consumer module!
[WARNING]: When you import the same blueprint into different modules, each module will create a new module instance
based on that specific blueprint, this may not seem obvious at first, but it happens because a blueprint is just that, a template defining the options
which will be used to build a module.
This means that if a blueprint exports a singleton provider, when imported into two separate modules, each module will have its own instance of that
specific singleton provider!
You should also keep in mind that once a blueprint has been encapsulated into a module, it can't be removed anymore as you can do with the modules!
Why should you use a ProviderModuleBlueprint?
You can always edit a property of the blueprint after creating it by doing:
const GarageModuleBlueprint = ProviderModule.blueprint({ id: 'GarageModuleBlueprint' });
// Later in your code
GarageModuleBlueprint.updateDefinition({
imports: [...GarageModuleBlueprint.imports, PorscheModule, FerrariModuleBlueprint]
});
// ...
const GarageModule = ProviderModule.create(GarageModuleBlueprint);
// or
ExistingModule.update.addImport(GarageModuleBlueprint);
OptionalblueprintOptions: ModuleBlueprintOptionsOptions specific to the Blueprint instance, see ModuleBlueprintOptions.
StaticcreateInstantiates a new instance of the IProviderModule class.
Note: Check also the blueprint method.
Holds a reference to the
AppModule.Static property needed in order to avoid introducing a cirular dependency between the
AppModuleinstance and theProviderModuleclass.