Skip to content

Commit

Permalink
Fixed for Xcode GM
Browse files Browse the repository at this point in the history
  • Loading branch information
AvdLee committed Sep 15, 2019
1 parent 01473bf commit 52eb42c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import Combine
## @Published properties
A [Property Wrapper](https://www.avanderlee.com/swift/property-wrappers/) that adds a `Publisher` to any property.

_Note: Xcode beta 2 does not support running this Playground page with the @Published property unfortunately._
_Note: Xcode Playgrounds don't support running this Playground page with the @Published property unfortunately._
*/
struct FormViewModel {
@Published var isSubmitAllowed: Bool = false
final class FormViewModel {
@Published var isSubmitAllowed: Bool = true
}

final class FormViewController: UIViewController {
Expand All @@ -21,12 +21,14 @@ final class FormViewController: UIViewController {
super.viewDidLoad()
viewModel.$isSubmitAllowed
.receive(on: DispatchQueue.main)
.print()
.assign(to: \.isEnabled, on: submitButton)
}
}

let formViewController = FormViewController(nibName: nil, bundle: nil)
print("Button enabled is \(formViewController.submitButton.isEnabled)")
formViewController.viewModel.isSubmitAllowed = true
formViewController.viewModel.isSubmitAllowed = false
print("Button enabled is \(formViewController.submitButton.isEnabled)")

//: [Next](@next)
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ enum RequestError: Error {
}

let URLPublisher = PassthroughSubject<URL, RequestError>()
URLPublisher.flatMap { requestURL in
let anyCancellable = URLPublisher.flatMap { requestURL in
return URLSession.shared.dataTaskPublisher(for: requestURL)
.mapError { error -> RequestError in
return RequestError.sessionError(error: error)
Expand Down

0 comments on commit 52eb42c

Please sign in to comment.