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

ReactiveCocoa

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
Avatar for nghialv nghialv
December 14, 2015

 ReactiveCocoa

Avatar for nghialv

nghialv

December 14, 2015
Tweet

More Decks by nghialv

Other Decks in Education

Transcript

  1. • Le Van Nghia (ΪΞ) • @nghialv (twitter: nghialv2607) ΞΧ΢ϯτ

    • CyberAgentʹ৽ଔೖࣾ • FRESH!ੜ์ૹ , AmebaΞϓϦ
  2. • ϓϩδΣΫτϝϯόʔ໿30໊ • αʔόʔ & Πϯϑϥ x 6 • Go

    1.5.2, Docker 1.9.0, AWS, Microservices, RESTful API (goji) • ϑϩϯτ x 6 • Node.js v4, TypeScript 1.6, React/Flux, SPA + SSR • iOS x 4 • Swift 2.1, ReactiveCocoa, MVVM • Android x 4 • Kotlin, Rx • σβΠφʔ x 3 • Sketch • πʔϧ • Slack + Hubot(ChatOps), Github Enterprise, CircleCI (Enterprise), Fabric, JIRA Agile, Mackerel…
  3. 2015೥ͷiOS։ൃ WWDC 2014 1.0 - closure, first-class functions - type

    safety and type inference - generics - tuples and multiple return values - seamless access to Objective C, C, C++ 2/2015 1.2 - incremental builds - faster executables - better compiler diagnostics - stability improvements 9/2015 2.0 - error handling model - guard, defer - protocol extension - protocol-oriented programming - ίϯύΠϧ࣌ؒ - ίϯύΠϥͷόά AmebaΞϓϦ FRESH!ੜ์ૹ - ReactiveCocoa - MVVMϞσϧ 1.0ಋೖ - ίϯύΠϧ࣌ؒ - ֎෦ϥΠϒϥϦͷෆ҆ఆ ίʔυ͕ଟ͘ͳͬͨ࣌఺ - 100% Swift 1.2 - MVCϞσϧ - Future - Result
  4. 2015೥ͷiOS։ൃ 12/2015 Open source - source code - swift package

    manager - core libraries - ports for Linux Fall 2016 3.0 FRESH!ੜ์ૹ - Swift2.0ʹҠಈ - ίϯύΠϧ͸΍͘ͳͬͨ
  5. ReactiveCocoa (RAC) is a Cocoa framework inspired by Functional Reactive

    Programming. It provides APIs for composing and transforming streams of values over time.
  6. ReactiveCocoa (RAC) is a Cocoa framework inspired by Functional Reactive

    Programming. It provides APIs for composing and transforming streams of values over time.
  7. ReactiveCocoa (RAC) is a Cocoa framework inspired by Functional Reactive

    Programming. It provides APIs for composing and transforming streams of values over time.
  8. event signal observe sink let (signal, sink) = Signal<String, ErrorType>.pipe()

    signal
 .observe { event in // hi } sink.sendNext("hi")
  9. event signal observe sink observe let (signal, sink) = Signal<String,

    ErrorType>.pipe() signal
 .observe { event in // hi } sink.sendNext("hi") signal
 .observe { event in // hi }
  10. ReactiveCocoa (RAC) is a Cocoa framework inspired by Functional Reactive

    Programming. It provides APIs for composing and transforming streams of values over time.
  11. event signal observe sink let (signal, sink) = Signal<String, ErrorType>.pipe()

    signal
 .map { string in string.uppercaseString } .observe { event in // “HI" } sink.sendNext("hi") transform hi HI
  12. throttle event signal observe sink throttle let (signal, sink) =

    Signal<Int, ErrorType>.pipe() signal .throttle(0.5, onScheduler: QueueScheduler()) .observe { num in // 1 // 4 } sink.sendNext(1) sink.sendNext(2) sink.sendNext(3) // after 0.5 second sink.sendNext(4)
  13. combinePrevious let (signal, sink) = Signal<Int, ErrorType>.pipe() signal .combinePrevious(0) .observe

    { pre, cur in // pre = 0, cur = 1 // pre = 1, cur = 2 } sink.sendNext(1) sink.sendNext(2)
  14. Transforming • map • filter • reduce • collect •

    mapError • observeOn • ignoreNil • timeoutWithError • take • delay • skip • takeUntil • combinePrevious • takeLast • throttle • promoteErrors
  15. ReactiveCocoa (RAC) is a Cocoa framework inspired by Functional Reactive

    Programming. It provides APIs for composing and transforming streams of values over time.
  16. • compose <A, B, C> (A -> B, B ->

    C) -> A -> C f1: A -> B f2: B -> C f3: C -> D f = f1ɾf2ɾf3 => f: A -> D
  17. zip let (numbersSignal, numbersSink) = Signal<Int, NoError>.pipe() let (lettersSignal, lettersSink)

    = Signal<String, NoError>.pipe() let newSignal = zip(numbersSignal, lettersSignal) newSignal .observe { event in
 println(event)
 } numbersSink.sendNext(1) // nothing printed lettersSink.sendNext("A") // prints (1, A) numbersSink.sendNext(2) // nothing printed lettersSink.sendNext("B") // prints (1, B) lettersSink.sendNext("C") // nothing printed lettersSink.sendNext("D") // nothing printed