Redux Flashcards

1
Q

Describe ‘compose’ in redux.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Describe createStore.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

describe combineReducers.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the 3 principles of Redux

A
  • 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

describe the redux workflow

A
  • 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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a thunk?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Describe Redux Observable.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly