Last active
February 12, 2019 17:54
-
-
Save Levi-Moreira/6c9c6e17e648ddd3e61a4a4ca7c92677 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 TopUsersViewModel @Inject constructor( | |
val usersRepository: UsersRepository | |
) : ViewModel() { | |
fun getUserList(): LiveData<PagedList<User>> { | |
val result = usersRepository | |
.getUsers() | |
.subscribeOn(Schedulers.io()) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.toFlowable(BackpressureStrategy.BUFFER) | |
return LiveDataReactiveStreams.fromPublisher(result) | |
} | |
fun dataLoadStatus(): LiveData<NetworkState> { | |
val result = usersRepository.getDataLoadStatus() | |
.subscribeOn(Schedulers.io()) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.toFlowable(BackpressureStrategy.BUFFER) | |
return LiveDataReactiveStreams.fromPublisher(result) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment