Gets all component references that match specified locator.
the locator to find a reference by.
forces to raise an exception if no reference is found.
a list with matching component references.
Gets all component references registered in this reference map.
a list with component references.
Gets locators for all registered component references in this reference map.
a list with component locators.
Gets an optional component reference that matches specified locator.
the locator to find references by.
a matching component reference or null if nothing was found.
Gets a required component reference that matches specified locator.
the locator to find a reference by.
a matching component reference.
Gets all component references that match specified locator.
the locator to find references by.
a list with matching component references or empty list if nothing was found.
Gets all component references that match specified locator. At least one component reference must be present. If it doesn't the method throws an error.
the locator to find references by.
a list with matching component references.
Puts a new reference into this reference map.
a locator to find the reference by.
a component reference to be added.
Removes a previously added reference that matches specified locator. If many references match the locator, it removes only the first one. When all references shall be removed, use removeAll method instead.
a locator to remove reference
the removed component reference.
Removes all component references that match the specified locator.
the locator to remove references by.
a list, containing all removed references.
Generated using TypeDoc
Interface for a map that holds component references and passes them to components to establish dependencies with each other.
Together with IReferenceable and IUnreferenceable interfaces it implements a Locator pattern that is used by PipServices toolkit for Inversion of Control to assign external dependencies to components.
The IReferences object is a simple map, where keys are locators and values are component references. It allows to add, remove and find components by their locators. Locators can be any values like integers, strings or component types. But most often PipServices toolkit uses Descriptor as locators that match by 5 fields: group, type, kind, name and version.
Descriptor
References
Example
export class MyController implements IReferenceable { public _persistence: IMyPersistence; ... public setReferences(references: IReferences): void { this._persistence = references.getOneRequired<IMyPersistence>( new Descriptor("mygroup", "persistence", "*", "*", "1.0") ); } ... } let persistence = new MyMongoDbPersistence(); let controller = new MyController(); let references = References.fromTuples( new Descriptor("mygroup", "persistence", "mongodb", "default", "1.0"), persistence, new Descriptor("mygroup", "controller", "default", "default", "1.0"), controller ); controller.setReferences(references);