valuesyou can access those values from any method called within the context of the Scope.
runmethod on the call stack:
cwas call from
bwhich was called from
awhich was called from the Scope's
cis in the Scope's context.
usemethod provide access to injected values that exist in our scope or any ancestors scope.
use. The two forms are equivalent and exist simply for convenience.
useis also typed.
somekeyhasn't been added to your Scope then a
MissingDependencyExceptionwill be thrown.
useis called for that ScopeKey and the ScopeKey is not in Scope then the default will be returned.
() =>for the default value to help with performance. The lambda provided to the
defaultargument will only be called if the ScopeKey is missing. This allows the default to call a potentially long running method.
Scope.withDefaultand you call
usewith a default value then the default value provided to
usewill take precedence.
usecan test if the ScopeKey exists by calling
hasScopeKeyin that it checks if a key is in scope. The difference is that if the key isn't in scope but has a default value then
hasScopeValuewill return true.