Guest User

Untitled

a guest
Jun 25th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. class PostListViewModel:BaseViewModel(){
  2. @Inject
  3. lateinit var postApi: PostApi
  4.  
  5. private lateinit var subscription: Disposable
  6.  
  7. init{
  8. loadPosts()
  9. }
  10.  
  11. private fun loadPosts(){
  12. subscription = postApi.getPosts()
  13. .subscribeOn(Schedulers.io())
  14. .observeOn(AndroidSchedulers.mainThread())
  15. .doOnSubscribe { onRetrievePostListStart() }
  16. .doOnTerminate { onRetrievePostListFinish() }
  17. .subscribe(
  18. { onRetrievePostListSuccess() },
  19. { onRetrievePostListError() }
  20. )
  21. }
  22.  
  23. private fun onRetrievePostListStart(){
  24.  
  25. }
  26.  
  27. private fun onRetrievePostListFinish(){
  28.  
  29. }
  30.  
  31. private fun onRetrievePostListSuccess(){
  32.  
  33. }
  34.  
  35. private fun onRetrievePostListError(){
  36.  
  37. }
  38. }
Add Comment
Please, Sign In to add comment