Skip to content

Instantly share code, notes, and snippets.

@GuilhE
Created April 14, 2022 13:22
Show Gist options
  • Save GuilhE/999dba8f9d6ee6f3413fa5a45711d8f1 to your computer and use it in GitHub Desktop.
Save GuilhE/999dba8f9d6ee6f3413fa5a45711d8f1 to your computer and use it in GitHub Desktop.
Medium articles - KMM with MVI+FSM
import SwiftUI
import Combine
import shared
public class TimerViewModelObservableObject : ObservableObject {
private var wrapped: TimerViewModel
@Published private(set) var state: TimerUiState
init(wrapped: TimerViewModel) {
self.wrapped = wrapped
state = wrapped.stateFlow.value as! TimerUiState
(wrapped.stateFlow.asPublisher() as AnyPublisher<TimerUiState, Never>)
.receive(on: RunLoop.main)
.assign(to: &$state)
}
deinit {
wrapped.onCleared()
}
func settingTime() {
wrapped.settingTime()
}
func setTime(seconds: Int32) {
wrapped.setTime(seconds: seconds)
}
//ramaining public functions...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment