react-code-dataset / wp-calypso /apps /notifications /src /panel /state /action-middleware /index.js
react-code-dataset / wp-calypso /apps /notifications /src /panel /state /action-middleware /index.js
Download wp-calypso/apps/notifications/src/panel/state/action-middleware/index.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 730 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/apps/notifications/src/panel/state/action-middleware/index.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/apps/notifications/src/panel/state/action-middleware/index.js
-
curl -L -o index.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/apps/notifications/src/panel/state/action-middleware/index.js
730 Bytes
| import notes from './notes'; | |
| import overrides from './overrides'; | |
| import suggestions from './suggestions'; | |
| import ui from './ui'; | |
| import { mergeHandlers } from './utils'; | |
| const mergedHandlers = mergeHandlers( notes, overrides, suggestions, ui ); | |
| export const middleware = ( handlers ) => ( store ) => ( next ) => ( action ) => { | |
| const handlerChain = handlers[ action.type ]; | |
| // if no handler is defined for the action type | |
| // then pass it along the chain untouched | |
| if ( ! handlerChain ) { | |
| return next( action ); | |
| } | |
| handlerChain.forEach( ( handler ) => handler( store, action ) ); | |
| return next( action ); | |
| }; | |
| export default ( customMiddleware = {} ) => | |
| middleware( mergeHandlers( customMiddleware, mergedHandlers ) ); | |