-
-
Save GuilhE/999dba8f9d6ee6f3413fa5a45711d8f1 to your computer and use it in GitHub Desktop.
Medium articles - KMM with MVI+FSM
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
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