Created
April 1, 2019 00:36
-
-
Save enginebai/97388f9e38b9731c0d903f9ca10c5047 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
class PostListViewModel : ViewModel() { | |
private val repo: PostRepository by inject() | |
fun getNewPostList(): Observable<List<NewPost>> { | |
return repo.getNewPostList() | |
} | |
} | |
class PostListFragment : Fragment { | |
private val viewModel by viewModel<PostListViewModel>() | |
override fun onViewCreated() { | |
viewModel.getNewPostList() | |
.subscribeOn(Schedulers.io()) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.subscribe { | |
// update list | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment