Closed blnked closed 10 years ago
Sorry, I don't fully understand the utility of this. Can you show us an example class that would implement this protocol, and specifically why it can't inherit from the RVMViewModel
class?
Sorry, I don't fully understand the utility of this. Can you show us an example class that would implement this protocol, and specifically why it can't inherit from the
RVMViewModel
class?
For clarity, I've created a quick example. Please, compare branches master
and protocol
.
Please pay attention to the difference of writing:
@property (nonatomic, strong) RVMViewModel<RVMDetailVM> *viewModel;
vs@property (nonatomic, strong) id<RVMDetailVM> viewModel;
It sounds like you just want to make it easier to refer to RVMViewModel
properties that also have your custom protocol. Is that correct?
If so, why not use a typedef:
typedef RVMViewModel<RVMDetailVM> *RVMDetailVM;
@property (nonatomic, strong) RVMDetailVM viewModel;
Yep, correct
You're right, it can be option, but I didn't see any differences between
typedef RVMViewModel<RVMDetailVM> *RVMDetailVM;
and
@property (nonatomic, strong) RVMViewModel<RVMDetailVM> *viewModel;
It's question about protocol as more flexible API of class. Perhaps, it only my opinion. you can close this pull request.
Anyway, thanks for excellent projects like ReactiveCocoa, ReactiveViewModel.
It's certainly true that protocols are more flexible.
However, the signals implemented in RVMViewModel
are very complex, and I don't think third-party implementations outside of the main class would be a good idea, so I don't want to encourage that with a protocol.
Thanks for the suggestion, and for discussing it, though! :sparkles:
However, the signals implemented in RVMViewModel are very complex, and I don't think third-party implementations outside of the main class would be a good idea, so I don't want to encourage that with a protocol.
Agreed! It's make sense.
Please, review request to inject protocol
Recently I faced to using multiple ViewModels with one common protocol. And you know, I don't understand why not use protocol to avoid some writting like
RVMViewModel <MyProtocol> *viewModel
. Because, in this case a ViewController doesn't may find anything fromRVMViewModel
for example:
thus, we get next ...
Perhaps, better to use in this case a protocol inheritance