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

MBL-1039: Refactor LoadingBarButtonItem to take a closure instead of a binding for save actions #1881

Merged
merged 1 commit into from Nov 8, 2023

Conversation

amy-at-kickstarter
Copy link
Contributor

📲 What

This refactors LoadingBarButtonItem to take a closure.

🤔 Why

This pattern more closely follows how Apple handles save actions (e.g. in the Button class), which will make our code a little bit more canonical.

✅ Acceptance criteria

  • Still able to submit a report
  • Still able to change your e-mail

@@ -74,17 +74,12 @@ struct ReportProjectFormView: View {
viewModel.inputs.viewDidLoad()
}
.onReceive(viewModel.$bannerMessage) { newValue in
showLoading = false
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is moved up in the view model

@@ -243,6 +244,10 @@ public final class ChangeEmailViewModelSwiftUIIntegrationTest: ChangeEmailViewMo
self.viewDidLoadProperty.value = ()
}

public func didTapSaveButton() {
self.saveTriggered.send(true)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactoring this to be a stream of voids would be a slightly bigger project; leaving that for another day.

// An API error happens.
// We need to catch this up here in flatMap, instead of in sink,
// because we don't want an API failure to cancel this pipeline.
// If the pipeline gets canceled, you can't re-submit after a failure.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was something interesting I noticed while testing. Any error in a pipeline cancels/finishes the entire pipeline.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good find! That's useful to know!

Copy link

codecov bot commented Nov 7, 2023

Codecov Report

Merging #1881 (46a835a) into main (36ea6fe) will decrease coverage by 0.01%.
The diff coverage is 10.34%.

@@            Coverage Diff             @@
##             main    #1881      +/-   ##
==========================================
- Coverage   83.83%   83.83%   -0.01%     
==========================================
  Files        1224     1224              
  Lines      111347   111349       +2     
  Branches    29599    29601       +2     
==========================================
- Hits        93350    93349       -1     
- Misses      16984    16989       +5     
+ Partials     1013     1011       -2     
Files Coverage Δ
...starter-iOS/SharedViews/LoadingBarButtonItem.swift 0.00% <0.00%> (ø)
...s/ChangeEmailViewModelSwiftUIIntegrationTest.swift 0.00% <0.00%> (ø)
...tures/ChangeEmail/Controller/ChangeEmailView.swift 0.00% <0.00%> (ø)
...Features/ReportProject/ReportProjectFormView.swift 0.00% <0.00%> (ø)
...ibrary/ViewModels/ReportProjectFormViewModel.swift 37.87% <15.00%> (-2.80%) ⬇️

... and 1 file with indirect coverage changes

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

@amy-at-kickstarter amy-at-kickstarter marked this pull request as ready for review November 7, 2023 18:06
Copy link
Contributor

@ifosli ifosli left a comment

Choose a reason for hiding this comment

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

Looks good!

// An API error happens.
// We need to catch this up here in flatMap, instead of in sink,
// because we don't want an API failure to cancel this pipeline.
// If the pipeline gets canceled, you can't re-submit after a failure.
Copy link
Contributor

Choose a reason for hiding this comment

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

Good find! That's useful to know!

@amy-at-kickstarter amy-at-kickstarter merged commit 67e4562 into main Nov 8, 2023
7 checks passed
@amy-at-kickstarter amy-at-kickstarter deleted the refactor/adyer/mb-1039 branch November 8, 2023 20:48
ifosli pushed a commit that referenced this pull request Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants