TyphoonOptionMatcher 与 conformsToProtocol
TyphoonOptionMatcher with conformsToProtocol
如果能用matcher根据协议select定义就好了,例如:
- (UIViewController *)viewControllerForViewModel:(id <IViewModel>)viewModel
{
return [TyphoonDefinition withOption:viewModel matcher:^(TyphoonOptionMatcher *matcher)
{
[matcher conformsToProtocol:@protocol(ILoginViewModel) use:[self loginViewController]];
[matcher conformsToProtocol:@protocol(IMainViewModel) use:[self mainScreenViewController]];
[matcher defaultUse:[self emptyScreen]];
}];
}
是否可以使用 Typhoon 现在拥有的功能或者可能有一些变通办法?
谢谢。
编辑:
我已经对 TyphoonOptionMatch 和 TyphoonOptionMatcher 进行了一些添加以具有 conformsToProtocol 选项,是否值得创建 PR?
台风选项匹配
@property (nonatomic) Protocol *proto;
....
+ (id)matchWithConformsToProto:(Protocol *)proto injection:(id)injection;
TyphoonOptionMatcher
- (void)conformsToProto:(Protocol *)aProtocol use:(id)injection
...
- (TyphoonOptionMatch *)matchForValue:(id)value {
...
BOOL isConformProto = (match.proto && [value conformsToProtocol:match.proto]);
此功能已在 3.4.5 中推出release
[matcher caseConformsToProtocol:@protocol(IMainViewModel)
use:[self mainScreenViewController]];
如果能用matcher根据协议select定义就好了,例如:
- (UIViewController *)viewControllerForViewModel:(id <IViewModel>)viewModel
{
return [TyphoonDefinition withOption:viewModel matcher:^(TyphoonOptionMatcher *matcher)
{
[matcher conformsToProtocol:@protocol(ILoginViewModel) use:[self loginViewController]];
[matcher conformsToProtocol:@protocol(IMainViewModel) use:[self mainScreenViewController]];
[matcher defaultUse:[self emptyScreen]];
}];
}
是否可以使用 Typhoon 现在拥有的功能或者可能有一些变通办法?
谢谢。
编辑: 我已经对 TyphoonOptionMatch 和 TyphoonOptionMatcher 进行了一些添加以具有 conformsToProtocol 选项,是否值得创建 PR?
台风选项匹配
@property (nonatomic) Protocol *proto;
....
+ (id)matchWithConformsToProto:(Protocol *)proto injection:(id)injection;
TyphoonOptionMatcher
- (void)conformsToProto:(Protocol *)aProtocol use:(id)injection
...
- (TyphoonOptionMatch *)matchForValue:(id)value {
...
BOOL isConformProto = (match.proto && [value conformsToProtocol:match.proto]);
此功能已在 3.4.5 中推出release
[matcher caseConformsToProtocol:@protocol(IMainViewModel)
use:[self mainScreenViewController]];