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 RxSwift | |
@discardableResult | |
func popped(to viewController: UIViewController) -> Observable<Void> { | |
currentViewController = viewController | |
return .empty() | |
} |
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 RxSwift | |
protocol UsersBaseServiceType { | |
func observeCurrentFriendRequests() -> Observable<YourDatabaseResultType> | |
} | |
final class UsersBaseService { | |
static let shared = UsersBaseService() | |
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 RxSwift | |
protocol MyViewModelServiceType { | |
func observeCurrentNumberOfFriendRequests() -> Observable<Int> | |
} | |
struct MyViewModelService: MyViewModelServiceType { | |
private let usersBaseService = UsersBaseService.shared | |
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
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> |
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 | |
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool { | |
// Manually creates the window and makes it visible. | |
window = UIWindow(frame: UIScreen.main.bounds) |
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 RxSwift | |
import RxCocoa | |
final class SceneCoordinator: SceneCoordinatorType { | |
fileprivate var window: UIWindow | |
var currentViewController: UIViewController | |
required init(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
import UIKit | |
enum SceneTransitionType { | |
case root | |
case push(animated: Bool) | |
case modal(animated: Bool) | |
// Add custom transtion types... | |
case pushToVC(stackPath: [UIViewController], animated: Bool) | |
} |
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 RxSwift | |
protocol SceneCoordinatorType { | |
init(window: UIWindow) | |
var currentViewController: UIViewController { get } | |
@discardableResult | |
func transition(to scene: Scene, type: SceneTransitionType) -> Observable<Void> |
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 RxSwift | |
protocol BindableType { | |
associatedtype ViewModelType | |
var viewModel: ViewModelType! { get set } | |
func bindViewModel() | |
} |
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 | |
extension Scene { | |
func viewController() -> UIViewController { | |
switch self { | |
case .firstScene(let viewModel): | |
let nc = UINavigationController(rootViewController: FirstSceneViewController()) |
NewerOlder