Open pinchukvd opened 7 years ago
I found a solution for this problem. We can change definition.key from configuration. It will look like this:
return [TyphoonDefinition withClass:[FavoritesRouter class] configuration:^(TyphoonDefinition *definition) {
definition.key = @"FavoritesModuleAssembly_router";
[definition injectProperty:@selector(viewController) with:[self view]];
}];
The solution seems to be ugly because we’ll have to change the definition.key on all definitions. @etolstoy Is it possible to delimit definitions on a namespaces, using typhoon functionality? In this article, you mentioned that the key is compound and consists of a random string and the name of the method. What has changed?
@jasesuperhero You can also consider namespacing your methods:
favoritesRouter SearchRouter
@jasperblues Yeah, sure. But if we use TyphoonAssemblies for MVVM or VIPER modules creation we’ll have problems with using common protocol or class with the same names in one module. Every VIPER module has view, presenter, interactor, also we have some runtime magic using the exact names. For example:
@protocol MVVMAssebly <NSObject>
@required
- (id)model;
- (id)view;
- (id)viewModel;
@end
Relates to: https://github.com/appsquickly/Typhoon/pull/446
In #446 pr we got the opportunity to create definitions with configs, that has specific definition.key. But in current case it's not useful, because we want to create definitions with uniq keys in range of one assembly and using configuration in code. I found the method -setDefinitionKeyRandomlyIfNeeded
, that can resolve current problem, but it will called, if key.length == 0. it's not very comfortable to set empty key in all definitions. Do you have any ideas? Maybe we can create pr with new initializers for definition, that set key to empty.
I have two properties in AppAssembly - SearchModuleAssembly and FavoritesModuleAssembly. AppAssembly, SearchModuleAssembly, FavoritesModuleAssembly are initial assemblies. It's throwing an exception on run "reason: 'Key 'router' is already registered.'".