Skip to content
Permalink
Browse files

applied suggestions

  • Loading branch information...
marcosgriselli authored and freak4pc committed May 6, 2019
1 parent 0056535 commit 5cd1536ca1e428bc2d94afa475ee01b917d3126e
Showing with 6 additions and 6 deletions.
  1. +6 −6 Documentation/Examples.md
@@ -136,7 +136,7 @@ self.usernameOutlet.rx.text
// Convenience for constructing synchronous result.
// In case there is mixed synchronous and asynchronous code inside the same
// method, this will construct an async result that is resolved immediately.
return Observable.just(Availability.invalid(message: "Username can't be empty."))
return Observable.just(.invalid(message: "Username can't be empty."))
}
// ...
@@ -150,10 +150,10 @@ self.usernameOutlet.rx.text
return API.usernameAvailable(username)
.map { available in
if available {
return Availability.available(message: "Username available")
return .available(message: "Username available")
}
else {
return Availability.taken(message: "Username already taken")
return .taken(message: "Username already taken")
}
}
// use `loadingValue` until server responds
@@ -168,9 +168,9 @@ self.usernameOutlet.rx.text
// Now we need to bind that to the user interface somehow.
// Good old `subscribe(onNext:)` can do that.
// That's the end of `Observable` chain.
.subscribe(onNext: { validity in
self.errorLabel.textColor = validationColor(validity)
self.errorLabel.text = validity.message
.subscribe(onNext: { [weak self] validity in
self?.errorLabel.textColor = validationColor(validity)
self?.errorLabel.text = validity.message
})
// This will produce a `Disposable` object that can unbind everything and cancel
// pending async operations.

0 comments on commit 5cd1536

Please sign in to comment.
You can’t perform that action at this time.