Redux Flashcards
Describe ‘compose’ in redux.
Composes functions from right to left. Each function in the parameter list is expected to have one argument and evaluates from right to left. The return value of the first value (rightmost function) is passed as the argument to the second value to its left and so on.
Describe createStore.
takes a reducer, initial values, and enhancers and returns a store object that comes with many helper methods as well as stores your global state tree.
describe combineReducers.
As your app grows more complex, you’ll want to split your reducing function into separate functions, each managing independent parts of the state.
The combineReducers helper function turns an object whose values are different reducing functions into a single reducing function you can pass to createStore.
What are the 3 principles of Redux
- Single source of truth - The state of your whole application is stored in an object tree within a single store.
- read only state (state can only be changed by actions)
- Redux only deals with pure functions. changes should only be made with pure functions.
describe the redux workflow
- Start with describing the role of redux (createStore, combineReducers…etc)
- Describe the role of react-redux ( component, container classes and connect.
- Describe mapping dispatch methods to props and state to props.
- describe reducers and actions.
Action creators create objects → objects are dispatched to the store → the store invokes reducers → reducers generate new state → listeners are notified of state updates.
What is a thunk?
A thunk is a piece of middleware for redux that allows us to write async code that interacts with the redux store.
Thunks are the recommended middleware for basic Redux side effects logic, including complex synchronous logic that needs access to the store, and simple async logic like AJAX requests.
Describe Redux Observable.
Redux observables is a middleware for redux that binds RxJS and Redux by providing a middleware that taps into your stream of actions and returns new actions. This is defined in something known as an Epic. similar to how reducers take a state and return new state, epics take actions and return new actions.
Redux observables are great for managing side effects and async code that involve your redux store.