ReactiveCocoa / ReactiveViewModel

Model-View-ViewModel, using ReactiveCocoa
MIT License
1.96k stars 259 forks source link

Error Handling in ViewModel #44

Closed iv-mexx closed 9 years ago

iv-mexx commented 9 years ago

This is just a quick question:

I have noticed that in the GroceryList, the GCYViewModel class inherits from RVMViewModel and adds the errors signal.

Is there a specific reason why this kind of error handling is not part of RVMViewModel directly?

Maybe its because the assumption, that all errors are handled equally (e.g. just display the error message on the screen) is too specific and its best practice to just subscribe to the error event of each Action of a viewModel individually and handle the error of that Action individually?

jspahrsummers commented 9 years ago

The primary reason is that RVMViewModel does not itself generate any errors, so it wouldn't make much sense to have RVMViewModel.errors.

It's easier for subclasses (perhaps even a project-specific base class) to declare themselves.

iv-mexx commented 9 years ago

Ok, thanks for the answer.

perhaps even a project-specific base class

Thats what I've been doing but the error handling was the only thing added to my own base class, so I was wondering why it was not part of RVMViewModel already.