GithubHelp home page GithubHelp logo

larryonoff / rex Goto Github PK

View Code? Open in Web Editor NEW

This project forked from raccommunity/rex

0.0 2.0 0.0 365 KB

ReactiveCocoa Extensions

License: MIT License

Ruby 1.34% Swift 98.09% Objective-C 0.57%

rex's Introduction

Rex Carthage compatible

Extensions for ReactiveCocoa that may not fit in the core framework.

New development targets RAC 4/Swift 2/Xcode 7. For RAC 3 support see the 0.5 release.

Signal

All Signal operators are available for SignaProducers too via explicit lifting.

filterMap

Applies transform to values from signal with non-nil results unwrapped and forwared on the returned signal. This is equivalent to map { โ€ฆ } .filter { $0 != nil } .map { $0! } but without creating extra intermediate signals.

func filterMap<U>(transform: T -> U?) -> Signal<U, E>
ignoreError

Wraps a signal in a version that drops Error events. By default errors are replaced with a Completed event but Interrupted can also be specified as replacement.

func ignoreError(#replacement: Event<T, NoError> = .Completed) -> Signal<T, NoError>
timeoutAfter

Forwards events from signal until it terminates or until interval time passes. This is nearly identical to timeoutWithError from RAC except any terminating event can be used for the timeout.

func timeoutAfter(interval: NSTimeInterval, withEvent event: Event<T, E>, onScheduler scheduler: DateSchedulerType) -> Signal<T, E>
uncollect

Flattens batches of elements sent on signal into each individual element. The inverse of collect. Requires signal values to conform to SequenceType.

func uncollect() -> Signal<T.Generator.Element, E>

SignalProducer

Operators specific to SignalProducer.

groupBy

Partitions values from producer into new producer groups based on the key returned from grouping. Termination events on the original producer are forwarded to each inner producer group.

func groupBy<K: Hashable>(grouping: T -> K) -> SignalProducer<(K, SignalProducer<T, E>), E>

UIKit Extensions

UIButton.rex_pressed

Flexible way to bind CocoaAction to the press of button. In addition the button will be disabled during the Action executing. Such behavior is convenient for tasks that require some time, like a download process in the example below.

let downloadAction = Action<UIButton, NSData, NSError> { _ in
    let url = NSURL(string: "https://github.com/neilpa/Rex/archive/master.zip")
    let request = NSURLRequest(URL: url!)
    return NSURLSession.sharedSession().rac_dataWithRequest(request).map { $0.0 }
}

downloadButton.rex_pressed.value = downloadAction.unsafeCocoaAction

License

Rex is released under the MIT license

rex's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.