{ { val stopwatchState = stopwatchUtil.state val formattedTimeString = stopwatchUtil.formattedTimeString fun start() = stopwatchUtil.start() fun pause() = stopwatchUtil.pause() fun resume() = stopwatchUtil.resume() fun reset() = stopwatchUtil.reset() fun destroy() = stopwatchUtil.destroy() }
{ val stopwatchState = stopwatchUtil.state val formattedTimeString = stopwatchUtil.formattedTimeString fun start() = stopwatchUtil.start() fun pause() = stopwatchUtil.pause() fun resume() = stopwatchUtil.resume() fun reset() = stopwatchUtil.reset() fun destroy() = stopwatchUtil.destroy() } ViewModel ViewModel ?
{ val stopwatchState = stopwatchUtil.state val formattedTimeString = stopwatchUtil.formattedTimeString fun start() = stopwatchUtil.start() fun pause() = stopwatchUtil.pause() fun resume() = stopwatchUtil.resume() fun reset() = stopwatchUtil.reset() fun destroy() = stopwatchUtil.destroy() } ViewModel Android Common class AppViewModel(private val stopwatchUtil: StopwatchUtil = StopwatchUtil()) : ViewModel() { { val stopwatchState = stopwatchUtil.state val formattedTimeString = stopwatchUtil.formattedTimeString fun start() = stopwatchUtil.start() fun pause() = stopwatchUtil.pause() fun resume() = stopwatchUtil.resume() fun reset() = stopwatchUtil.reset() fun destroy() = stopwatchUtil.destroy() }
{ val stopwatchState = stopwatchUtil.state val formattedTimeString = stopwatchUtil.formattedTimeString fun start() = stopwatchUtil.start() // 혹은 suspend로 구현 후 viewModelScope 사용 fun pause() = stopwatchUtil.pause() fun resume() = stopwatchUtil.resume() fun reset() = stopwatchUtil.reset() override fun destroy() { super.destroy() stopwatchUtil.destroy() } }