Skip to content

Instantly share code, notes, and snippets.

@GianpaMX
Created September 5, 2020 20:39
Show Gist options
  • Save GianpaMX/e06080f6affb8abd9aa5da2ca0948ee5 to your computer and use it in GitHub Desktop.
Save GianpaMX/e06080f6affb8abd9aa5da2ca0948ee5 to your computer and use it in GitHub Desktop.
class ClockViewModel @Inject constructor(
observeState: ObserveState,
private val nextState: NextState,
private val errorChannel: BroadcastChannel<Throwable>,
private val defaultDispatcher: CoroutineDispatcher
) : ViewModel() {
val viewState: LiveData<ClockViewState> = observeState()
.map { it.toViewState() }
.flowOn(defaultDispatcher)
.catch { errorChannel.send(it) }
.asLiveData(viewModelScope.coroutineContext)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment