-
Notifications
You must be signed in to change notification settings - Fork 269
Quick Start
Jasper Blues edited this page Aug 9, 2017
·
49 revisions
Setting up a Dependency Injection container couldn't be more easy.
Add the method names in the header. This will allow compile-time checking and IDE code-completion.
@interface MiddleAgesAssembly : TyphoonAssembly
- (Knight*)basicKnight;
- (Knight*)cavalryMan;
- (id<Quest>)defaultQuest;
@end
Let's perform an Initializer Injection.
- (Knight*)basicKnight
{
return [TyphoonDefinition withClass:[Knight class]
configuration:^(TyphoonDefinition* definition)
{
[definition useInitializer:@selector(initWithQuest:)
parameters:^(TyphoonMethod *initializer) {
[initializer injectParameterWith:[self defaultQuest]];
}];
}];
}
- (id<Quest>)defaultQuest
{
return [TyphoonDefinition withClass:[CampaignQuest class]];
}
MiddleAgesAssembly *mas = [[MiddleAgesAssembly new] activate];
Knight* knight = [mas basicKnight];
And we're done!
- We can proceed from one object graph to another, by injecting the assembly.
- For fully Typhoon-powered apps we can bootstrap using plist integration. This gives AppDelegate injection and tight Storyboard integration, including the use of Auto-injection (Objective-C) macros.
Before activation each method in a TyphoonAssembly returns a TyphoonDefinition. After activation we'll use the same interface to return built instances. Since the main use for your assembly interfaces will be emitting built components, you can declare the return type as the type being built.
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.