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

模組化的Swift架構(一) Redux入門

模組化的Swift架構(一) Redux入門

2022/3/15 ios@Taipei分享
介紹SwiftRex

A3d3b179955bdea9fc05b3251f1b1f10?s=128

Hai Feng Kao

June 23, 2022
Tweet

More Decks by Hai Feng Kao

Other Decks in Programming

Transcript

  1. Redux入⾨ Hai Feng Kao 模組化的Swift架構(⼀)

  2. None
  3. Action0 State0 Action1 State1 Action2 State2

  4. None
  5. Redux • Single source of truth • Read-only state •

    New state is created by pure function
  6. Swift的Redux框架 • ReSwift • swift-composable-architecture • SwiftRex

  7. None
  8. Redux的優點 • Debug容易 • AOP簡單 • 和SwiftUI契合度⾼

  9. Redux缺點 • 同功能的程序碼散落各處 • 處理side e ff ect⿇煩 • Async

    operation • External state management
  10. µFeatures Architecture • A µFeature contains • Example target •

    Test target • Framework target
  11. None
  12. µFeatures + Redux • A µFeature’s framework target contains •

    Actions • States • Reducers • Middlewares
  13. Demo

  14. Redux的缺點 • 當新增⼀個µFeature • 把µFeature的reducer加入reducer list • 把µFeature的middleware加入middleware list •

    把µFeature的state加入global state • 處理reducer、middleware、state的投影(projection)