Experimental
The resolution constraint bit-flag for SkipSelf.
This function can be used to construct a bitmask for use in the dependencies array of a service. While this can be used publicly, it is mainly for use within TypeDI; it allows you to configure specific constraints for use when resolving a specific service.
const constraintBitMask = SkipSelf();
if (constraintBitMask & ResolutionConstraintFlag.Self) {
console.log('The dependency will be resolved recursively from the parent.');
}
Here is an example of this constraint as part of a service declaration:
const NAME = new Token<string>('name');
const childContainer = Container.ofChild(Symbol());
@Service({ container: childContainer }, [
[NAME, SkipSelf()]
])
class MyService {
constructor (private name: string) {
// In this example, $name would evaluate to Joanna instead
// of Mike. This is due to the SkipSelf decorator.
}
}
childContainer.set({ id: NAME, value: 'Mike' });
Container.set({ id: NAME, value: 'Joanna' });
childContainer.get(MyService);
Generated using TypeDoc
Begin searching from the parent container to resolve this identifier.
The constraints supported are listed in ResolutionConstraintFlag.