Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.