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
class Brew { | |
var temp = 0.0 | |
} | |
class BrewViewController: UIViewController { | |
@IBOutlet weak var tempLabel: UILabel! | |
var brew = Brew() | |
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
class Brew { | |
var temp: Float = 0.0 | |
} | |
class BrewViewModel : NSObject { | |
var brew = Brew() | |
dynamic var temp: Float = 0.0 { | |
didSet { | |
self.brew.temp = temp | |
} |
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
NSURLSession.sharedSession().rac_dataWithRequest(request) | |
|> map { data, URLResponse in | |
return data | |
} |
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
syncBrewAction = Action { brewState in | |
if let jsonData:AnyObject = BrewState.encode(brewState).value { | |
let requestResult = self.requestWithBody("api/brew", method: "POST", body: JSON(jsonData)) | |
if let requestResultValue = requestResult.value { | |
return NSURLSession.sharedSession().rac_dataWithRequest(requestResultValue) | |
|> map { data, URLResponse in | |
return data | |
} | |
} | |
} |
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
cocoaActionSync = CocoaAction(brewManager.syncBrewAction, input: brewState.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
var syncBrewAction: Action<BrewState, NSData, NSError>! |
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
self.brewManager.syncBrewAction.errors | |
|> observeOn(UIScheduler()) | |
|> observe(next: { error in | |
UIAlertView(title: "Error creating brew", message: error.localizedDescription, delegate: nil, cancelButtonTitle: "OK").show() | |
}) |
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
let validName = MutableProperty(false) | |
validName <~ self.brewState.producer | |
|> map{ $0.name.value.characters.count > 0 } |
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
validBeer <~ combineLatest(hasPhases.producer, validName.producer) | |
|> map { $0 && $1 } |
OlderNewer