Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Getting Started with ReactiveCocoa v4.1.0

Getting Started with ReactiveCocoa v4.1.0

Yasuhiro Inami

April 13, 2016
Tweet

More Decks by Yasuhiro Inami

Other Decks in Programming

Transcript

  1. Hot & Cold Observables • Hot Observable ‗ • always

    active (may lose data if not subscribed) • uses same underlying source (broadcasting) • Cold Observable ❄ • paused until subscription • clones underlying source (not broadcasting)
  2. Signal Operations • Transforming: map, mapError, scan, reduce, ... •

    Filtering: filter, take, takeUntil, skip, sampleOn, ... • Combining: flatten (Merge/Concat/Latest), combineLatest, zip, flatMap, flatMapError, ... • Timing: delay, throttle, timeoutWithError, ... • Utility: observeOn, materialize, dematerialize, ...
  3. SignalProducer Operations • Transforming: map, mapError, scan, reduce, ... •

    Filtering: filter, take, takeUntil, skip, sampleOn, ... • Combining: flatten (Merge/Concat/Latest), combineLatest, zip, flatMap, flatMapError, ... • Timing: delay, throttle, timeoutWithError, ... • Utility: observeOn, materialize, dematerialize, ... • Producer-Only: startOn, concat, retry, etc...
  4. Signal / SignalProducer • Signal • Container for observers (for

    broadcasting) • .pipe = pair of (Signal, Observer) = Subject • SignalProducer • Container for startHandler (for cloning) • .buffer = pair of (SignalProducer, Observer) = ReplaySubject
  5. Other data types • Observer: Wrapper of Event -> ()

    • Event: .Next, .Failed, .Completed, .Interrupted • Scheduler: GCD / NSThread wrapper • Disposable: Stateful container of () -> () • Property: Latest value + Signal(Producer) • Action: Stateful container of Input -> SignalProducer
  6. Compared to other FRPs... • Protocol-oriented, no abstract classes &

    subclassing • Functional, much less types to learn • Separation of Signal & SignalProducer • No shareReplay, refCount (ConnectableObservable) • Typed errors • combineLatest(o1, o2, ...) ... no mixed error types • property <~ signal ... only NoError is allowed
  7. Recap • ReactiveCocoa has separated hot & cold observables •

    Signal • SignalProducer • Type safe, including generic Error type • Use RAC if you like Result<T, E> more than Result<T> • RAC is beautiful !✨