Skip to content

Refactor ImmuTablePresenter/Controller/VC - #4791

Merged
koke merged 1 commit into
developfrom
fix/refactor-immutable-presenter-take-2
Feb 8, 2016
Merged

Refactor ImmuTablePresenter/Controller/VC#4791
koke merged 1 commit into
developfrom
fix/refactor-immutable-presenter-take-2

Conversation

@koke

@koke koke commented Feb 8, 2016

Copy link
Copy Markdown
Member

The main goal is to remove visible from ImmuTablePresenter, since it
doesn't really belong there. Presenter is a thing that can "present" view
controllers: usually a UIViewController, but implemented as a protocol so it's
testable.

But then I realized, the Controller doesn't really need a reference to
Presenter, or the parent View Controller. The only thing that needs that is
ImmuTable (for the callbacks), and we can pass the presenter when requesting
the table view model (renamed). This is similar to the previous solution, but
avoids the chicken-and-egg problem when initiailizing. And because of this, it
removes 4 assertions/preconditions that are now guaranteed at compile time.

The visible observable is still exposed on ImmuTableViewController, but
the VC is the one pausing the subscription to tableViewModel and errorMessage,
instead of relying on the controller. I like this slightly less semantically,
but it makes everything much simpler with initialization.

Needs Review: @frosty

The main goal is to remove `visible` from `ImmuTablePresenter`, since it
doesn't really belong there. Presenter is a thing that can "present" view
controllers: usually a UIViewController, but implemented as a protocol so it's
testable.

But then I realized, the Controller doesn't really need a reference to
Presenter, or the parent View Controller. The only thing that needs that is
ImmuTable (for the callbacks), and we can pass the presenter when requesting
the table view model (renamed). This is similar to the previous solution, but
avoids the chicken-and-egg problem when initiailizing. And because of this, it
removes 4 assertions/preconditions that are now guaranteed at compile time.

The `visible` observable is still exposed on ImmuTableViewController, but
the VC is the one pausing the subscription to tableViewModel and errorMessage,
instead of relying on the controller. I like this slightly less semantically,
but it makes everything much simpler with initialization.

protocol ImmuTablePresenter: class {
var visible: Observable<Bool> { get }
func push(controllerGenerator: ImmuTableRowControllerGenerator) -> ImmuTableAction

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your previous version of this PR added a present method here, too. Should it be in this version?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not being used yet, so I think I'll add it on the plans list changes, which need to present the details modally

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

koke added a commit that referenced this pull request Feb 8, 2016
…-presenter-take-2

Refactor ImmuTablePresenter/Controller/VC
@koke
koke merged commit 146df95 into develop Feb 8, 2016
@koke
koke deleted the fix/refactor-immutable-presenter-take-2 branch February 8, 2016 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants