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

Redux 番外篇

CJ
October 20, 2018

Redux 番外篇

CJ

October 20, 2018
Tweet

More Decks by CJ

Other Decks in Programming

Transcript

  1. Reducer design Reducer signature func reducer(action: Action, state: State) ->

    State Reducer, Pure Function: state needs to be copied and modified Performance of `Copy`?
  2. Swift / ObjC Class Copy Shallow Copy: Not worked… True

    Deep Copy • ObjC: NSKeyedArchiver & NSKeyedUnarchiver • Swift: Codable & JSONEncoder & JSONDecoder • 2000X+ slower
  3. Swift / ObjC Class Copy Deep Copy with NSCopying •

    copyWithZone: • init(array:copyItems:) • Faster
  4. Redux State Design Use struct!
 Eliminate duplicates State Normalization (Data

    shared in multi ViewControllers) Substate? Release unused / outdated data?