Skip to content

Instantly share code, notes, and snippets.

View IsaAliev's full-sized avatar

Isa Aliev IsaAliev

  • Moscow, Russia
View GitHub Profile
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
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()
import Foundation
import Bond
class ViewModel {
let name = Observable<String?>(nil)
let greeting = Observable<String?>(nil)
func sayHello() {
greeting.value = "Hello, \(name.value ?? "")"
}
import Foundation
class ViewModel {
var name: String?
var greeting: String?
func sayHello() {
greeting = "Hello, \(name ?? "")"
}
}
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()
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.
import UIKit
class ViewController: UIViewController, StateAwareView, AlertStateStrategyProvider, LoadingStateStrategyProvider {
var model = ViewModel()
override func viewDidLoad() {
super.viewDidLoad()
bindWithState()
model.setup()
import Foundation
class ViewModel: StatyViewModel {
var state = SObservable<State?>(nil)
func setup() {
setupStateController(BasicStateController.self)
let inState = LoadingState()
stateController.transitTo(inState)
import Foundation
class BasicStateController: StateController {
var stateQueue = Queue<State>()
weak var observer: CurrentStateObserver?
required init() {}
func transitTo(_ newState: State) {
import Foundation
protocol CurrentStateObserver: class {
func didChangeStateTo(_ state: State)
}
fileprivate struct AssociatedKey {
static var stateController = "kStateController"
}