-
Notifications
You must be signed in to change notification settings - Fork 269
TyphoonLoadedView
Imagine case when we have an UITableView
with custom cell's with some dependencies like Presenter, Animator, Router, ViewModel, etc. How you will be passing this dependencies to your custom cell?
For solving this problem was implemented TyphoonLoadedView
.
TyphoonLoadedView
works really simple.
It's just override - (id)awakeAfterUsingCoder:(NSCoder *)aDecoder
, search view definition for typhoon key from [TyphoonComponentFactory factoryForResolvingUI]
and returns replacement view from definition.
Getting started
@interface CustomTableViewCell : UITableViewCell
@property (strong, nonatomic) TableViewCellViewModel *viewModel;
@end
Notice : For TyphoonLoadedView we need to set Restoration ID, it's will be your typhoon key for definition.
In the last step you just need to add definitions in your some assembly:
- (UITableViewCell *)customTableViewCell
{
return [TyphoonDefinition withClass:[CustomTableViewCell class] configuration:^(TyphoonDefinition *definition) {
[definition injectProperty:@selector(viewModel) with:[self tableViewCellViewModel]];
}];
}
- (TableViewCellViewModel *)tableViewCellViewModel
{
return [TyphoonDefinition withClass:[TableViewCellViewModel class] configuration:^(TyphoonDefinition *definition) {
[definition injectProperty:@selector(titleLabelString) with:@"Test"];
}];
}
Done!
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.