Skip to content

Contains replacements for the RAC and RACObserve macros in Swift and adds multiple cast methods.

License

Notifications You must be signed in to change notification settings

AvdLee/ALReactiveCocoaExtension

Repository files navigation

ALReactiveCocoaExtension

Version License Platform

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

The pod includes extensions for SignalProducer.

SignalProducer extension

This pod includes an extension for the new SignalProducer. This brings the methods we're familiar with from earlier versions of ReactiveCocoa.

let producer = SignalProducer<String, NSError>(value: "testValue")
    
// Prints "producer started!"
producer.onStarting { () -> () in
    print("producer started!")
}.start()
    
// Prints "testValue"
producer.onNext { (object) -> () in
    print(object)
}.start()
    
// Prints "testValue", can be used to cast AnyObjects for example
producer.onNextAs { (string:String) -> () in
    print(string)
}.start()
    
// Prints "testValue", can be used to cast AnyObjects for example
producer.startWithNextAs { (string:String) -> () in
    print(string)
}
    
// Prints "Error Domain=sample.domain Code=-1 "(null)""
let errorProducer = SignalProducer<String, NSError>(error:NSError(domain: "sample.domain", code: -1, userInfo: nil))
errorProducer.onError { (error) -> () in
    print(error)
}.start()

Requirements

  • This pod requires ReactiveCocoa 5.0.0 and up
  • Swift 3.0
  • iOS 8+
  • tvOS 9+
  • watchOS 2+

Installation

ALReactiveCocoaExtension is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "ALReactiveCocoaExtension"

Swift version vs Pod version

Swift version Pod version
3.X >= 4.0.0
2.3 3.0.3

Author

Antoine van der Lee, https://twitter.com/twannl https://www.avanderlee.com

License

ALReactiveCocoaExtension is available under the MIT license. See the LICENSE file for more info.

About

Contains replacements for the RAC and RACObserve macros in Swift and adds multiple cast methods.

Resources

License

Stars

Watchers

Forks

Packages

No packages published