Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class SignInPresenter(private val api: ApiController, view: SignInView, private val state: SignInState) {
- private val view = WeakReference(view)
- fun signIn(email: String, password: String) {
- api.signIn(email, password).enqueue(object : RetrofitCallback<User>() {
- override fun onSuccess(t: User) {
- state.user = t
- view.get()?.onSignIn(t)
- }
- override fun onError(t: Throwable) {
- view.get()?.onError(t)
- }
- })
- }
- interface SignInView {
- fun onSignIn(t: User)
- fun onError(t: Throwable) // is IOException | AccountInactive | Unauthorized | ContractViolation
- }
- interface SignInState {
- var user: User?
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement