Skip to content
This repository was archived by the owner on Dec 6, 2018. It is now read-only.

Conversation

@ashfurrow
Copy link
Owner

No description provided.

Copy link
Collaborator

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.

@jspahrsummers
Copy link
Collaborator

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 loading property to the FRPPhotoViewModel (as mentioned above) would open up more interesting testing opportunities, as well as getting into the image loading behaviors of the other VMs.

@ashfurrow
Copy link
Owner Author

Thanks for the feedback! I'll have to get on those tonight.

@ashfurrow
Copy link
Owner Author

I've updated OCMock to support class method mocks. I need to update the tests, and the book, to reflect that fact.

ashfurrow added a commit that referenced this pull request Dec 28, 2013
[WIP] Reactive View Model Refactoring & Testing
@ashfurrow ashfurrow merged commit ea99937 into master Dec 28, 2013
@ashfurrow ashfurrow deleted the reactiveviewmodel branch December 28, 2013 14:48
Copy link
Collaborator

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];

Copy link
Owner Author

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!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants