Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manage pledge configuration outputs #838

Merged
merged 10 commits into from
Sep 13, 2019

Conversation

Scollaco
Copy link
Contributor

📲 What

Adds outputs on the ManageViewPledgeViewController in order to configure each section (subview) separately.

🤔 Why

This will avoid merge conflicts (or make them less bad) when more than one engineer start working on that screen.

🛠 How

  • Implementing an output for each subview
  • Adding tests for the outputs

@@ -3,15 +3,15 @@ import Library
import Prelude
import UIKit

final class ManagePledgeViewController: UIViewController {
final class ManageViewPledgeViewController: UIViewController {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the old name is better 😬 what made you change it to ManageViewPledgeViewController?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The main reason is that we will use the same screen to Manage and View pledge.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay makes sense! 👍

@Scollaco Scollaco marked this pull request as ready for review September 13, 2019 15:41
@@ -93,33 +93,37 @@ public final class ProjectPamphletViewModel: ProjectPamphletViewModelType, Proje
.map(unpack)

let goToManagePledge = ctaButtonTapped
.filter { canShowManageViewPledgeScreen($0.0, state:$0.2) }
.filter { canShowManageViewPledgeScreen($0.0, state: $0.2) }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The changes on this file were made by SwiftFormat.

Copy link
Contributor

@ifbarrera ifbarrera left a comment

Choose a reason for hiding this comment

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

Couple minor comments!

@@ -3,15 +3,15 @@ import Library
import Prelude
import UIKit

final class ManagePledgeViewController: UIViewController {
final class ManageViewPledgeViewController: UIViewController {
Copy link
Contributor

Choose a reason for hiding this comment

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

Okay makes sense! 👍

public final class ManageViewPledgeViewModel:
ManageViewPledgeViewModelType, ManageViewPledgeViewModelInputs, ManageViewPledgeViewModelOutputs {
public init() {
let projectAndReward = self.projectAndRewardSignal
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we usually use .combineLatest here to ensure that both signals have fired at least once.

Copy link
Contributor Author

@Scollaco Scollaco Sep 13, 2019

Choose a reason for hiding this comment

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

The problem with .combineLatest here is that will change the variable's type by combining the signals type. So instead of Signal<(Project, Reward), Never>, it would become Signal<((Project, Reward), Void), Never>. The .takeWhen guarantees that the .projectAndRewardSignal only emits when viewDidLoad emits without changing the original type. Does it make sense?

Copy link
Contributor

Choose a reason for hiding this comment

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

It does change the signature, but that's not usually an issue because we can do .map(first).

I think problem with using .takeWhen is it that it doesn't wait for both signals to fire at least once 🤔 from the description of .takeWhen: "Emits the most recent value of selfwhenother emits.".

If the most recent of self (ie. projectAndRewardSignal) isn't there because that signal hasn't fired once, then it wouldn't work. Most of the time it would probably be fine, but we don't control when viewDidLoad gets called because it's a lifecycle function - I'm concerned there could be a race condition where somehow viewDidLoad gets called before we can call configureWith(project:reward).

cc @justinswart any feedback/insight on this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, @ifbarrera is correct here in that we would want to use combineLatest because that negates the concern about the order in which these signals emit. Using takeWhen we must ensure that configure(with:) is called first so that it has a value to take when viewDidLoad emits. By combining the two we're allowed to call these inputs in any order. Our preference and the pattern we typically use for this is combineLatest 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

@Scollaco can you please make sure to make this change in a subsequent PR?


self.vm.inputs.viewDidLoad()

self.title.assertValue(Strings.Manage_your_pledge())
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use the actual values of these strings in here? It's better to be more explicit about what you're testing against:

self.title.assertValue("Manage your pledge")


self.vm.inputs.viewDidLoad()

self.title.assertValue(Strings.View_your_pledge())
Copy link
Contributor

Choose a reason for hiding this comment

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

Here too 🙏

@Scollaco Scollaco merged commit e2abed4 into master Sep 13, 2019
@Scollaco Scollaco deleted the manage-pledge-configuration-outputs branch September 13, 2019 18:03
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.

None yet

3 participants