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

The latest info of ReactiveSwift and ReactiveCocoa

7ddcca09c00a2744b983974225447d19?s=47 Sho Ikeda
September 16, 2017

The latest info of ReactiveSwift and ReactiveCocoa

iOSDC Japan 2017でのLT発表資料です #iosdc

https://iosdc.jp/2017/

7ddcca09c00a2744b983974225447d19?s=128

Sho Ikeda

September 16, 2017
Tweet

Transcript

  1. The latest info of ReactiveSwift and ReactiveCocoa @ikesyo iOSDC Japan

    2017 2017-09-16 Sat #iosdc
  2. @ikesyo • ͍͚͠ΐʔʗ஑ా ᠳ • ͸ͯͳ@ژ౎ • https://twitter.com/ikesyo • https://github.com/ikesyo

  3. None
  4. None
  5. RAC 5.0

  6. RAC 5.0 • Repository Split • API Design • Signal

    • SignalProducer • Properties • Atomic • Others
  7. Repository Split • ReactiveSwift: 2.0 • ReactiveCocoa: 6.0 • ReactiveObjC:

    3.0 (Nullability Annotations, Lightweight Generics) • ReactiveObjCBridge: 2.0 (with RAS 2.0 and ReactiveObjC 3.0, Tuple Bridging)
  8. RAS 2.0 & RAC 6.0

  9. Signal • Safer Signal lifetime semantics: • #355 Revisit changes

    to the Signal lifetime semantics to improve tooling interoperability. • #463 Send interrupted when an input observer deinitializes. • Signal ʹΠϕϯτΛૹΓࠐΉinput observer͕อ࣋͞Εͳ͘ ͳͬͨΒ Signal ͕தஅʢഁغʣ͞ΕΔ • InstrumentsͰϝϞϦʔϦʔΫͱ൑அ͞Ε͍ͯͨՕॴΛղফ
  10. SignalProducer • SignalProducer resource management: • #334 Lifetime-based producer resource

    management • Before: SignalProducer<Int, NoError> { observer, disposable in guard disposable.isDisposed else { return } ... if someCondition { disposable.dispose() // Not desirable } }
  11. SignalProducer • SignalProducer resource management: • #334 Lifetime-based producer resource

    management • After: SignalProducer<Int, NoError> { observer, lifetime in guard lifetime.hasEnded else { return } ... if someCondition { observer.sendInterrupted() // Desirable } }
  12. SignalProducer • Reduced overhead for all SignalProducer lifted operators: •

    #140 Less hops in operator lifting. • ಺෦࣮૷ͷมߋͰύϑΥʔϚϯεվળ
  13. Properties • ValidatingProperty: • #182 Mutable Validating Property. • όϦσʔγϣϯՄೳͳՄมϓϩύςΟʔ

  14. Disposables • SimpleDisposable and ActionDisposable has been folded into AnyDisposable:

    • #412 s/(ActionDisposable|SimpleDisposable)/ AnyDisposable/g • AnyDisposable ͷΠχγϟϥΠβʔҧ͍ʹ౷߹ AnyDisposable() // SimpleDisposable() AnyDisposable { ... } // ActionDisposable { ... }
  15. Swift 3.2+ • Smart KeyPaths support: • #435 Overload map()

    to support key paths let signal: Signal<String, NoError> let mapped = signal.map(\String.count) // Signal<Int, NoError> let mapped2 = signal.map { $0.count }
  16. Swift 3.2+ • Smart KeyPaths support: • #440 BindingTarget +

    Smart Key Paths. let target: BindingTarget<Int> = BindingTarget( lifetime: lifetime, object: object, keyPath: \.value ) let property = MutableProperty(1) target <~ property // object.value == 1 property.value = 2 // object.value == 2
  17. ReactiveCocoa • Foundation: Object Interception • Method Call Interception let

    appearing = viewController.reactive.trigger(for: #selector(UIViewController.viewWillAppear(_:))) • Object Lifetime object.reactive.lifetime.ended.observeCompleted(doCleanup) • Expressive, Safe Key Path Observation let producer = object.reactive.values(forKeyPath: #keyPath(key)) .take(during: self.reactive.lifetime) let property = DynamicProperty<String>(object: person, keyPath: #keyPath(person.name))
  18. ReactiveCocoa • AppKit & UIKit: UI bindings • UI Bindings:

    nameLabel.reactive.text <~ person.name • Controls and User Interactions preferences.allowsCookies <~ toggle.reactive.isOnValues textField.reactive.continuousTextValues.map { $0.characters.count } button.reactive.pressed = CocoaAction(viewModel.commit)
  19. ReactiveCocoa • Smart KeyPaths support • #3489 Reactive key path

    subscript. label.reactive[\.text] <~ viewModel.title
  20. And more...

  21. ! Happy Reactive Coding!! !

  22. Thank you❗"