Skip to content

Instantly share code, notes, and snippets.

import RxSwift
import Action
protocol MyViewModelInputsType {
// Inputs headers
}
protocol MyViewModelOutputsType {
// Outputs headers
}
@Herakleis
Herakleis / ViewModel+RealLifeExample.swift
Last active April 27, 2019 19:59
ViewModel+RealLifeExample
import RxSwift
import Action
enum SceneStateOutput {
case idle
case sendingNoRecipient
case sendingSomeRecipients(sendingList: [String: String])
case sending
}
@Herakleis
Herakleis / ViewController+Template.swift
Last active August 19, 2017 16:59
ViewController+Template
import RxSwift
import RxCocoa
import Action
final class ViewController: UIViewController, BindableType {
// UI Elements
fileprivate var aButton = ViewController._aButton()
fileprivate var anotherButton = ViewController._aButton()
fileprivate let logo = ViewController._logo()
@Herakleis
Herakleis / Singleton+AuthManager.swift
Created August 18, 2017 20:56
Singleton+Template
import RxSwift
import RxSwiftExt
enum AuthenticationStatus {
case none
case error(AuthServiceError)
case user(String)
}
final class AuthManager {
@Herakleis
Herakleis / Singleton+Template.swift
Created August 18, 2017 20:58
Singleton+Template
final class Singleton {
static let shared = Singleton()
private init() { }
}
@Herakleis
Herakleis / Scene.swift
Last active August 19, 2017 14:55
Scene+Template
import Foundation
enum Scene {
// Sub-group of scenes related to each other
// E.g.: all scenes part of a login process
case firstScene(FirstSceneViewModel)
case secondScene(SecondSceneViewModel)
// Another sub-group of scenes related to each other
@Herakleis
Herakleis / Scene+ViewControllerTemplate.swift
Last active August 19, 2017 15:16
Scene+ViewControllerTemplate
import UIKit
extension Scene {
func viewController() -> UIViewController {
switch self {
case .firstScene(let viewModel):
let nc = UINavigationController(rootViewController: FirstSceneViewController())
@Herakleis
Herakleis / BindableType.swift
Created August 19, 2017 15:28
BindableType
import UIKit
import RxSwift
protocol BindableType {
associatedtype ViewModelType
var viewModel: ViewModelType! { get set }
func bindViewModel()
}
@Herakleis
Herakleis / SceneCoordinatorType.swift
Created August 19, 2017 15:57
SceneCoordinatorType
import UIKit
import RxSwift
protocol SceneCoordinatorType {
init(window: UIWindow)
var currentViewController: UIViewController { get }
@discardableResult
func transition(to scene: Scene, type: SceneTransitionType) -> Observable<Void>
@Herakleis
Herakleis / SceneTransitionType.swift
Created August 19, 2017 16:15
SceneTransitionType
import UIKit
enum SceneTransitionType {
case root
case push(animated: Bool)
case modal(animated: Bool)
// Add custom transtion types...
case pushToVC(stackPath: [UIViewController], animated: Bool)
}