Successfully reported this slideshow.

Time traveling with ReSwift

1

Share

Loading in …3
×
1 of 66
1 of 66

More Related Content

Related Books

Free with a 14 day trial from Scribd

See all

Related Audiobooks

Free with a 14 day trial from Scribd

See all

Time traveling with ReSwift

  1. 1. Time traveling with ReSwift @EliSawic
  2. 2. About me Eliasz Sawicki Blog: www.eliaszsawicki.com Twitter: @EliSawic @EliSawic
  3. 3. ReSwift @EliSawic
  4. 4. ReSwift is a Redux-like implementation of the unidirectional data flow architecture in Swift. @EliSawic
  5. 5. Plan • How did it all start? @EliSawic
  6. 6. Plan • How did it all start? • How does it work? @EliSawic
  7. 7. Plan • How did it all start? • How does it work? • What are my thoughts? @EliSawic
  8. 8. How did it all start? @EliSawic
  9. 9. What do we use? @EliSawic
  10. 10. React @EliSawic
  11. 11. Flux @EliSawic
  12. 12. Redux @EliSawic
  13. 13. Unidirectional Data Flow @EliSawic
  14. 14. Unidirectional Data Flow • one direction of state change • immutable state • modified by pure functions @EliSawic
  15. 15. DevTools @EliSawic
  16. 16. Recording @EliSawic
  17. 17. Time travel @EliSawic
  18. 18. Fun to work with @EliSawic
  19. 19. Dan Abramov @EliSawic
  20. 20. ReSwift @EliSawic
  21. 21. How does it work? @EliSawic
  22. 22. Core Elements • State • Actions • Reducers • Store @EliSawic
  23. 23. State @EliSawic
  24. 24. State @EliSawic
  25. 25. State struct AppState: StateType, HasNavigationState { var user: User var navigationState: NavigationState } @EliSawic
  26. 26. Actions @EliSawic
  27. 27. Actions struct UpdateUserName: Action { let name: String init(_ name: String) { self.name = name } } @EliSawic
  28. 28. Action Creator @EliSawic
  29. 29. Reducer @EliSawic
  30. 30. Reducer (Action, State?) -> State @EliSawic
  31. 31. Update state func handleAction(action: Action, state: AppState?) -> AppState { return AppState( user: userReducer(action, user: state?.user), navState: navReducer(action, navState: state?.navState) ) } @EliSawic
  32. 32. Reducer func userReducer(action: Action, user: User?) -> User { var resultUser = user ?? User() switch action { case let action as UpdateUserName: resultUser.name = action.name case let action as UpdateUserSurname: resultUser.surname = action.surname case let action as UpdateUserPresentationTitle: resultUser.presentationTitle = action.title default: break } return resultUser } @EliSawic
  33. 33. Store @EliSawic
  34. 34. Receives our letters @EliSawic
  35. 35. Manage changes @EliSawic
  36. 36. Notify about changes @EliSawic
  37. 37. Store protocol Store { init(reducer: Reducer, state: State) func subscribe(subscriber: Subscriber) func dispatch(action: Action) } @EliSawic
  38. 38. @EliSawic
  39. 39. Event @EliSawic
  40. 40. Send letter @EliSawic
  41. 41. Receive letters @EliSawic
  42. 42. Manage changes @EliSawic
  43. 43. Notify about changes @EliSawic
  44. 44. React to state changes @EliSawic
  45. 45. What are my thoughts? @EliSawic
  46. 46. DevTools @EliSawic
  47. 47. Remember @EliSawic
  48. 48. Keep reducers fast @EliSawic
  49. 49. No side effects in Reducers @EliSawic
  50. 50. Avoid heavy application state @EliSawic
  51. 51. One way of changing state @EliSawic
  52. 52. Why? @EliSawic
  53. 53. Easy to understand what is going on @EliSawic
  54. 54. Easy testing @EliSawic
  55. 55. DevTools - Time traveling, Hot reloading @EliSawic
  56. 56. Fixing bugs with friends @EliSawic
  57. 57. Why not? @EliSawic
  58. 58. Overwhelming @EliSawic
  59. 59. Boilerplate @EliSawic
  60. 60. Many ReSwift components are in POC state @EliSawic
  61. 61. Easy to get stuck @EliSawic
  62. 62. Against the framework @EliSawic
  63. 63. Check them out! • Karl Bowden - @karlbowden • Benjamin Encz - @benjaminencz • Aleksander Rendtslev - @ARendtslev • Dan Abramov - @danAbramov @EliSawic
  64. 64. Check these out! • https://karlbowden.com/reswift-prezzo/ • https://realm.io/news/benji-encz-unidirectional-data-flow- swift/ • https://github.com/reactjs/redux • https://github.com/ReSwift/ReSwift @EliSawic
  65. 65. Conclusion @EliSawic
  66. 66. Thank you for your attention @EliSawic

×