Skip to content

Instantly share code, notes, and snippets.

@Herakleis
Created August 19, 2017 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Herakleis/837d8e05ea029baf1b4a94c7187218c8 to your computer and use it in GitHub Desktop.
Save Herakleis/837d8e05ea029baf1b4a94c7187218c8 to your computer and use it in GitHub Desktop.
SceneCoordinator+Action
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