Created
January 21, 2019 06:43
-
-
Save michalbujalski/a271f4daacc038b2ba956fc50aa04dba to your computer and use it in GitHub Desktop.
This file contains 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
data class Contact(val name:String, val phoneNum:String) | |
interface ContactsListsApi{ | |
fetchContacts(): Single<List<Contact>> | |
} | |
interface ContactsListsContract{ | |
interface View{ | |
fun showProgress() | |
fun hideProgress() | |
fun setData(contacts: List<Contact>) | |
} | |
interface Presenter{ | |
fun fetchContacts() | |
} | |
} | |
class ContactsListPresenter(val view: ContactsListsContract.View, val api:ContactsListsApi): ContactsListsContract.Presenter { | |
override fun fetchContacts(){ | |
view.showProgress() | |
fetchContacts() | |
.subscribe( | |
{ | |
view.hideProgress() | |
view.setData(it) | |
}, | |
{ | |
view.hideProgress() | |
view.showError(it.message ?: "Unknown error") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment