|
Download wp-calypso/client/state/console-dispatch/README.md from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.14 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/console-dispatch/README.md
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/state/console-dispatch/README.md
-
curl -L -o README.md https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/console-dispatch/README.md
1.14 kB
| # Console Dispatcher | |
| **A Redux [store enhancer](https://github.com/reactjs/redux/blob/HEAD/docs/Glossary.md#store-enhancer)** | |
| The console dispatcher is a Redux store enhancer which provides access to the Redux store from the developer console when running in a browser environment. | |
| This can be used for debugging and interactive design. | |
| The expected store properties and methods are directly available at the top level. | |
| Additionally, [`actionTypes`](/client/state/action-types.js) are available at the top level. | |
| ## Functionality | |
| ### Redux methods | |
| The four primary methods that Redux stores provide are all available at the root level. | |
| - `dispatch()` | |
| - `getState()` | |
| - `replaceReducer()` | |
| - `subscribe()` | |
| An alias to `getState()` has been provided for terseness in the console: `state`. | |
| `state` is a defined property with a getter which calls `getState()` and thus can be directly substituted. | |
| ```js | |
| // these two are equivalent from within the console | |
| getState().ui.selectedSiteId; | |
| state.ui.selectedSiteId; | |
| // dispatch an action | |
| // actionTypes are available on the console | |
| dispatch( { type: actionTypes.USER_SETTINGS_REQUEST } ); | |
| ``` | |