File tree Expand file tree Collapse file tree 2 files changed +8
-10
lines changed
app/src/main/java/com/fmt/github Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -21,15 +21,13 @@ open class BaseViewModel : ViewModel() {
2121 }
2222 }
2323
24- fun <T > emit (block : suspend LiveDataScope <T >.() -> T ): LiveData <T > {
25- return liveData {
26- try {
27- mStateLiveData.value = LoadState
28- emit(block())
29- mStateLiveData.value = SuccessState
30- } catch (e: Exception ) {
31- mStateLiveData.value = ErrorState (e.message)
32- }
24+ fun <T > emit (block : suspend LiveDataScope <T >.() -> T ): LiveData <T > = liveData {
25+ try {
26+ mStateLiveData.value = LoadState
27+ emit(block())
28+ mStateLiveData.value = SuccessState
29+ } catch (e: Exception ) {
30+ mStateLiveData.value = ErrorState (e.message)
3331 }
3432 }
3533}
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ class ReposViewModel(private val mReposRepository: ReposRepository) : BaseViewMo
1919 }
2020
2121 fun checkRepoStarred (owner : String , repo : String ): LiveData <Boolean > = emit {
22- mReposRepository.starRepo (owner, repo).code() == 204
22+ mReposRepository.checkRepoStarred (owner, repo).code() == 204
2323 }
2424
2525 fun starRepo (owner : String , repo : String ): LiveData <Boolean > = emit {
You can’t perform that action at this time.
0 commit comments