-
Notifications
You must be signed in to change notification settings - Fork 268
Scopes
[Types of Injections](Assembling Components with Blocks) | What can be Injected | Modules | Scopes | Obtaining Built Components | [Integration Testing](Integration Testing)
Typhoon provides the following scopes:
##TyphoonScopeObjectGraph (default)
This scope is essential (and unique to Typhoon) for mobile and desktop applications. When a component is resolved, any dependencies with the object-graph will be treated as shared instances during resolution. Once resolution is complete they are not retained by the TyphoonComponentFactory. This allows instantiating an entire object graph for a use-case (say for a ViewController), and then discarding it when that use-case has completed.
##TyphoonScopePrototype
Indicates that a new instance should always be created by Typhoon, whenever this component is obtained from an assembly or referenced by another component.
##TyphoonScopeSingleton
Indicates that Typhoon should retain the instance that exists for as long as the TyphoonComponentFactory exists.
##TyphoonScopeWeakSingleton
Indicates that a shared instance should be created as long as necessary. When your application's classes stop referencing this component it will be deallocated until needed again.
#Setting Scope for a Component:
- (id)rootController
{
return [TyphoonDefinition withClass:[RootViewController class] configuration:^(TyphoonDefinition* definition)
{
definition.scope = TyphoonScopeSingleton;
}];
}
Something still not clear? How about posting a question on StackOverflow.
Get started in two minutes.
Get familiar with Typhoon.
- Types of Injections
- What can be Injected
- Auto-injection (Objective-C)
- Scopes
- Storyboards
- TyphoonLoadedView
- Activating Assemblies
Become a Typhoon expert.
For contributors or curious folks.