Closed rock88 closed 7 years ago
first of all - typhoon have pretty good documentation there is page that might interest you: https://github.com/appsquickly/typhoon/wiki/types-of-injections
I would use base and abstract definitions, something like: 1) make interface without optionals to describe base components / settings 2) create base definition
- (id<ViewControllerRequiredShit> )abstractViewController
{
return [TyphoonDefinition withClass:[UIViewController class] // change it to your base class
configuration:^(TyphoonDefinition* definition) {
// i hope that you want to inject more common things than title! using base definitions like that is quite poor
[[definition injectProperty:@selector(title) with:@"TitleA"];
// don't inject it here! you don't know what presenter you will be need
[definition injectProperty:@selector(output) with:[self presenter]];
}];
}
3) override it and make it happen
- (YourVerySpecialViewController *)verySpecialViewController
{
return [TyphoonDefinition withParent:[self abstractViewController]
class:[YourVerySpecialViewController class]
configuration:^(TyphoonDefinition* definition) {
definition.scope = TyphoonScopeWeakSingleton;
[definition injectProperty:@selector(registered) with:@(NO)];
[definition injectProperty:@selector(presenter) with:[self.presentersAssembly yourVerySpecialPresenter]];
}];
}
it's probably little bit different than you planned but in this way it will work if it comes to building base definitions
something like injecting base presenter in base view controller - i have tried it but it was misconception of using dependency injection make ViewControllers assembly for some part of application, make assembly for presenters, make property in view controllers assembly of type presenters assembly and use it to inject presenter into view controller
@CurlyHeir abstract definition seems like to my first option, with all minuses.
injecting base presenter in base view controller
For example - needs build assembly for login screen with loginViewController <-> loginPresenter relation. But in other target I need to use other loginViewController or loginPresenter class (or subclass). Maybe for this case best solution - create new loginViewController definition with other selector name and use origin as parent. But for complex relation like definitions for VIPER module this not usable.
make ViewControllers assembly for some part of application, make assembly for presenters, make property in view controllers assembly of type presenters assembly and use it to inject presenter into view controller
For this solution instead of one assembly for one VIPER module we will have four for each component and one for assembly all components in module. Maybe it's ok, I try it, thanks!
@rock88 ok, if you will write some code, just post it here, maybe then i will try to make some workaround or try different approach
Closing due to inactivity. If you still experience this issue, feel free to reopen it.
Hello, I want to use some default assembly with few definitions with few default property injection. This assembly may be like:
Next I make
AssemblyB
(subclasses fromAssemblyA
) with same definition name and want to changeUIViewController
class (and maybe few new property injections):In this case Typhoon framework entered in forever loop.
For resolve this issues I use several solutions:
AssemblyB
(For this options all definitions, which use original-viewController
will be not use new, for example-[AssemblyA presenter]
will be injected with original-viewController
);definition.parent
and copy/paste all injection from-[AssemblyA viewController]
(copy/paste - bad solution 😕 )Maybe you can explain me how best solution for this case, ideally for me - if
definition.parent = [super viewController]
will be work.Thanks in advance for any help!