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 Foundation | |
import ReactiveKit | |
protocol Command: class, BindableProtocol { | |
func execute() | |
} | |
extension Command { | |
func bind(signal: Signal<Void, Never>) -> Disposable { | |
return signal.observeNext { [weak self] _ in |
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 Bond | |
class ViewController: UIViewController { | |
@IBOutlet weak var greetingLabel: UILabel! | |
@IBOutlet weak var nameTextField: UITextField! | |
@IBOutlet weak var sayHelloButton: UIButton! | |
let model = 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
import Foundation | |
import Bond | |
class ViewModel { | |
let name = Observable<String?>(nil) | |
let greeting = Observable<String?>(nil) | |
func sayHello() { | |
greeting.value = "Hello, \(name.value ?? "")" | |
} |
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 Foundation | |
class ViewModel { | |
var name: String? | |
var greeting: String? | |
func sayHello() { | |
greeting = "Hello, \(name ?? "")" | |
} | |
} |
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 | |
class ViewController: UIViewController { | |
@IBOutlet weak var greetingLabel: UILabel! | |
@IBOutlet weak var nameTextField: UITextField! | |
@IBOutlet weak var sayHelloButton: UIButton! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
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
pragma solidity >=0.4.22 <0.7.0; | |
contract SimpleAuction { | |
// Parameters of the auction. Times are either | |
// absolute unix timestamps (seconds since 1970-01-01) | |
// or time periods in seconds. | |
address payable public beneficiary; | |
uint public auctionEndTime; | |
// Current state of the auction. |
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 | |
class ViewController: UIViewController, StateAwareView, AlertStateStrategyProvider, LoadingStateStrategyProvider { | |
var model = ViewModel() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
bindWithState() | |
model.setup() |
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 Foundation | |
class ViewModel: StatyViewModel { | |
var state = SObservable<State?>(nil) | |
func setup() { | |
setupStateController(BasicStateController.self) | |
let inState = LoadingState() | |
stateController.transitTo(inState) |
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 Foundation | |
class BasicStateController: StateController { | |
var stateQueue = Queue<State>() | |
weak var observer: CurrentStateObserver? | |
required init() {} | |
func transitTo(_ newState: State) { |
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 Foundation | |
protocol CurrentStateObserver: class { | |
func didChangeStateTo(_ state: State) | |
} | |
fileprivate struct AssociatedKey { | |
static var stateController = "kStateController" | |
} |