Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // FROM THIS
- loginFinished = loginTaps
- .asObservable()
- .withLatestFrom(usernameAndPassword)
- .flatMapLatest { (username, password) in
- provider.request(GitHub.Token(username: username, password: password))
- .retry(3)
- .trackActivity(activityIndicator)
- .observeOn(MainScheduler.instance) // when I remove this guy, unit tests pass
- }
- .checkIfRateLimitExceeded()
- .mapJSON()
- .doOn(onNext: { json in
- var appToken = Token()
- appToken.token = json["token"] as? String
- })
- .map { json in
- if let message = json["message"] as? String {
- return LoginResult.Failed(message: message)
- } else {
- return LoginResult.OK
- }
- }
- .asDriver(onErrorJustReturn: LoginResult.Failed(message: "Oops, something went wrong"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement