Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Redux
- =====
- State management library
- designing state of user
- list
- create user
- manage user
- user:{
- users:[],
- user:{
- username:'',
- password:''
- },
- currentUserId:''
- }
- Three Principles
- Single source of truth
- State is read-only
- The only way to change the state is to emit an action, an object describing what happened.
- Changes are made with pure functions
- folder structure
- ================
- actions/action creators
- reducers
- store
- read => store.getState()
- subscribe => store.subscribe(()=>console.log(''))
- dispatch => store.dispatch(action)
- container
- * place where dispatching actions
- components
- * dump to display data passed from container
- middlewares
- * custom middlewares
- * Thunk , Promise , SAGA
- actions
- =======
- type = 'LOGIN_ATTEMPT'
- createStore(
- reducer,
- middleware(
- ),
- ini
- )
- Parts
- ====
- State
- * Represent data / model of the application
- * Entire application should contain single object
- Actions
- * a plain object that contains type and payload( optional )
- * async and sync
- * by default sync but async can possible with middlewares such as Thunk, Promise, Saga
- ActionCreators
- * functions which trigger to manage the state
- * Data manipulataion is should be through actions
- * dispatch function will trigger action
- Reducers
- * functions that accept current state and action but return new state (copy).
- * by combining multiple Reducers and then pass it to the store called reducer composition.
- * just for manipulate data using functional javascript
- * return existing state if reducer's action not match with any action passed.
- ReducerComposition
- * for store we should pass a single reducer for that combinig is called
- * combineReducers for redux is used
- Middlewares
- * is a function execute during action trigger
- * just like node js middlewares
- Store
- * represent applications data
- * use createStoer()
- * inject in the component using Provier from 'react-redux'
- * store.subscribe(). store.getState()
- ContainerComponent
- * component that contain logics to subscripe data from store
- PresentationalComponent
- * display data from ContainerComponent.
Add Comment
Please, Sign In to add comment