We use view models along with coordinator to manage the app entire flow & interactions. We don't use any special library to build view models. In general:
router
property related to their Coordinator — Manage App Flow.import RxCocoa
import RxSwift
import XCoordinator
final class SomeViewModel {
private let router: WeakRouter<SomeRoute>
private let authToken = BehaviorRelay<String?>(value: nil)
init(router: WeakRouter<SomeRoute>) {
self.router = router
}
// MARK: Data
public func authInit() {
// Call network...
authToken.accept("TOKEN")
}
// MARK: Actions
public func goIntoApp() {
router.trigger(.main)
}
public func logout() {
router.trigger(.onboarding)
}
}