Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Combine
## @Published properties
A [Property Wrapper](https://www.avanderlee.com/swift/property-wrappers/) that adds a `Publisher` to any property.

_Note: Xcode Playgrounds don't support running this Playground page with the @Published property unfortunately._
_Note: Xcode Playgrounds doesn't support running this Playground page with the @Published property unfortunately._
*/
final class FormViewModel {
@Published var isSubmitAllowed: Bool = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ subscription.cancel()
*/
extension CombineCompatible where Self: UISwitch {
/// As the `UISwitch.isOn` property does not support KVO this publisher can become handy.
/// The only downside is that it does not work with programmatically changing `isOn`, but it only responds to UI changes.
/// The only downside is that it does not work with programmatically changing `isOn`, it only responds to UI changes.
var isOnPublisher: AnyPublisher<Bool, Never> {
return publisher(for: [.allEditingEvents, .valueChanged]).map { $0.isOn }.eraseToAnyPublisher()
}
Expand All @@ -105,4 +105,3 @@ switcher.isOnPublisher.assign(to: \.isEnabled, on: submitButton)
switcher.isOn = true
switcher.sendActions(for: .valueChanged)
print(submitButton.isEnabled)
//: [Next](@next)
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,5 @@ let breakSubscription = subject
.breakpoint(receiveOutput: { value in
value == "Hello!"
})

//: [Next](@next)