Last active
February 19, 2017 13:29
-
-
Save srdanrasic/dd415566cdf1b63ce48ce7252297f8a0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Authentication { | |
| public typealias Credentials = (username: String, password: String) | |
| public let credentials: SafeObserver<Credentials> | |
| public let token: SafeSignal<Token> | |
| public init(client: SafeClient) { | |
| let credentials = SafePublishSubject<Credentials>() | |
| self.token = credentials | |
| .flatMapLatest { username, password in | |
| let request = API.User.login(username: username, password: password) | |
| return client.response(for: request) | |
| } | |
| self.credentials = credentials.toObserver() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment