-
Notifications
You must be signed in to change notification settings - Fork 91
Reactive View Model Refactoring & Testing #24
Conversation
FRP/FRPPhotoViewController.m
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be part of the view model's behavior, IMO. You could add a loading property to the VM (informed by didBecomeActiveSignal and photoImage), and then the VC just has to observe that.
|
The VMs are kinda light on real presentation logic right now, so the tests aren't super useful, but they're still good to have. Adding a |
|
Thanks for the feedback! I'll have to get on those tonight. |
|
I've updated OCMock to support class method mocks. I need to update the tests, and the book, to reflect that fact. |
[WIP] Reactive View Model Refactoring & Testing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably a bit much for your book, but this operation can be written without any state or pesky strongifying:
RAC(self, loading) = [[[RACObserve(self, model)
sample:self.didBecomeActiveSignal]
map:^(FRPPhotoModel *model) {
return [[[[[[FRPPhotoImporter
fetchPhotoDetails:model]
catch:^(NSError *error) {
NSLog(@"Could not fetch photo details: %@", error);
return [RACSignal empty];
}]
doCompleted:^{
NSLog(@"Fetched photo details.");
}]
ignoreValues]
startWith:@NO]
concat:[RACSignal return:@YES]];
}]
concat];There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a great idea!
No description provided.