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

DIY your own Combine framework

Li-Heng Hsu
September 22, 2019

DIY your own Combine framework

Li-Heng Hsu

September 22, 2019
Tweet

Other Decks in Programming

Transcript

  1. Builder pattern • For constructing instances • Like initializer, factory

    method… 1. Create a builder struct 2. Store construction info in it 3. Call its build() method to construct a product
  2. map(_:) method • There are different worlds in code •

    World of Uncertainty, World of Plurality, World of Erroneous... • Instances in these worlds can't be manipulated normally
  3. Imperative Functional Metaphor Unwrap values Stack operations Optional if let

    x = x { /* ... */ } x.map { x in /* ... */ } Collection for i in x { /* ... */ } x.forEach { i in /* ... */ } Result if case .success(let x) = result { /* ... */ } result.map { x in /* ... */ }