Redux Demo in SwiftUI
The main goal that Redux is trying to offer is predictable state management. The way that Redux tries to accomplish this is through having a single state tree. This state tree is an object that stores the entire state for an application. Now that all state is stored in one location
Views have read-only access to the Application State and the only way to update the State is through a dispatcher, which we can call from the views.
Actions contain the data that we have to process to mutate the App State, and a reference to Reducer(which is a pure function) that will be used to perform the updates.
Store manages the State of every single object in the app.
Dispatcher manages all the data flow in the app, It receives an action and sends it to the Store for processing.
The function that returns the new state needs to be a pure function. Pure functions are integral to how the state in Redux applications is updated. By definition, pure functions:
- Return the same result if the same arguments are passed in
- Depend solely on the arguments passed into them
- Do not produce side effects, such as API requests and I/O operations
For our purposes, the most important feature of a pure function is that it's predictable. If we have a function that takes in our state and an action that occurred, the function should (if it's pure!) return the exact same result every single time.
Middleware will allow you to enhance your store by hooking into and intercepting actions before they reach any reducers.
- created by Hager Elsayed
Users API consuming in this demo from this website

