Skip to content

Instantly share code, notes, and snippets.

@srdanrasic
Last active February 19, 2017 13:29
Show Gist options
  • Select an option

  • Save srdanrasic/dd415566cdf1b63ce48ce7252297f8a0 to your computer and use it in GitHub Desktop.

Select an option

Save srdanrasic/dd415566cdf1b63ce48ce7252297f8a0 to your computer and use it in GitHub Desktop.
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