Created
August 19, 2017 16:53
-
-
Save Herakleis/837d8e05ea029baf1b4a94c7187218c8 to your computer and use it in GitHub Desktop.
SceneCoordinator+Action
This file contains hidden or 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
lazy var pushScene: CocoaAction = { | |
return Action { [weak self] in | |
guard let strongSelf = self else { return .empty() } | |
// The ViewModel is created and its dependencies are injected | |
let newSceneViewModel = NewSceneViewModel(service: NewSceneService(), coordinator: strongSelf.coordinator) | |
// A reference to the corresponding scene is created to be passed to the coordinator | |
let newScene = Scene.newScene(newSceneViewModel) | |
// The coordinator calls the specified transition function and returns an Observable<Void> | |
// that will complete once the transition is made (one `Void` element will be pushed onto the | |
// Observable) | |
return strongSelf.coordinator.transition(to: newScene, type: .push(animated: true)) | |
} | |
}() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment