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 RxFlow | |
enum DemoStep: Step { | |
case apiKey | |
case apiKeyIsComplete | |
case movieList | |
case moviePicked (withMovieId: Int) | |
case castPicked (withCastId: Int) |
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 RxFlow | |
import UIKit | |
class WatchedFlow: Flow { | |
var root: UIViewController { | |
return self.rootViewController | |
} | |
private let rootViewController = UINavigationController() |
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 RxFlow | |
import RxSwift | |
class WatchedViewModel: Stepper { | |
let movies: [MovieViewModel] | |
init(with service: MoviesService) { | |
// we can do some data refactoring in order to display | |
// things exactly the way we want (this is the aim of a ViewModel) |
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
private func navigationToDashboardScreen () -> [NextFlowItem] { | |
let tabbarController = UITabBarController() | |
let wishlistStepper = WishlistStepper() | |
let wishListFlow = WishlistWarp(withService: self.service, | |
andStepper: wishlistStepper) | |
let watchedFlow = WatchedFlow(withService: self.service) | |
Flows.whenReady(flow1: wishListFlow, flow2: watchedFlow, block: { [unowned self] | |
(root1: UINavigationController, root2: UINavigationController) in | |
let tabBarItem1 = UITabBarItem(title: "Wishlist", |
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 RxFlow | |
import UIKit | |
class WatchedFlow: Flow { | |
... | |
private let service: MoviesService | |
init(withService service: MoviesService) { | |
self.service = service |
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 UIKit | |
import RxFlow | |
import RxSwift | |
import RxCocoa | |
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
let disposeBag = DisposeBag() | |
var window: UIWindow? |
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
/// Observable that triggers a bool indicating if | |
/// the current Presentable is being displayed | |
var rxVisible: Observable<Bool> { get } | |
/// Single triggered when this presentable is displayed | |
/// for the first time | |
var rxFirstTimeVisible: Single<Void> { get } | |
/// Single triggered when this presentable is dismissed | |
var rxDismissed: Single<Void> { get } |
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
extension Reactive where Base: UIViewController { | |
/// Observable, triggered when the view has appeared for the first time | |
public var firstTimeViewDidAppear: Single<Void> { | |
return sentMessage(#selector(Base.viewDidAppear)).map { _ in | |
return Void() | |
}.take(1).asSingle() | |
} | |
/// Observable, triggered when the view is being dismissed |
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
nextPresentable.rxFirstTimeVisible.subscribe(onSuccess: { [unowned self, | |
unowned nextPresentable, | |
unowned nextStepper] (_) in | |
// we listen to the presentable's Stepper. | |
// For each new Step value, we trigger a new navigation process | |
// this is the core principle of the whole RxFlow mechanism | |
// The process is paused each time the presentable is not currently displayed | |
// for instance when another presentable is above it in the VCs hierarchy. | |
nextStepper.steps | |
.pausable(nextPresentable.rxVisible.startWith(true)) |
OlderNewer