Skip to content

Instantly share code, notes, and snippets.

@edwardIshaq
Created March 25, 2016 22:23
Show Gist options
  • Save edwardIshaq/7ada399d8784416176d5 to your computer and use it in GitHub Desktop.
Save edwardIshaq/7ada399d8784416176d5 to your computer and use it in GitHub Desktop.
//
// Rac4VC.swift
// Pop
//
// Created by Edward Ishaq on 3/25/16.
// Copyright © 2016 Zuno. All rights reserved.
//
import UIKit
import Result
import ReactiveCocoa
class Rac4VC: UIViewController {
@IBOutlet weak var button: UIButton!
func demoAction() -> Action<AnyObject?, String, NoError> {
return Action{ input in
return SignalProducer<String, NoError>{ sink, dispose in
sink.sendNext("Success")
sink.sendCompleted()
}
}
}
@IBAction func buttonAction(sender: UIButton) {
demoAction()
.apply(sender)
.on { (next: String) in
print(next)
}
.onError{ (actionError: ActionError<NoError>) in
print(actionError)
}
.start()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment