Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class PostListViewModel:BaseViewModel(){
- @Inject
- lateinit var postApi: PostApi
- private lateinit var subscription: Disposable
- init{
- loadPosts()
- }
- private fun loadPosts(){
- subscription = postApi.getPosts()
- .subscribeOn(Schedulers.io())
- .observeOn(AndroidSchedulers.mainThread())
- .doOnSubscribe { onRetrievePostListStart() }
- .doOnTerminate { onRetrievePostListFinish() }
- .subscribe(
- { onRetrievePostListSuccess() },
- { onRetrievePostListError() }
- )
- }
- private fun onRetrievePostListStart(){
- }
- private fun onRetrievePostListFinish(){
- }
- private fun onRetrievePostListSuccess(){
- }
- private fun onRetrievePostListError(){
- }
- }
Add Comment
Please, Sign In to add comment