-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Data: Add redux-routine package for synchronous generator flow (#8096)
* Packages: Add package `redux-routine` * Packages: Throw rejected promise as error to generator * Data: Add support for controls via redux-routine * Core Data: Partially reimplement resolvers as controls * Data: Port controls as data plugin * Data: Revert deprecation of async generator * Docs: Add note about plugin opt-in for controls * ReduxRoutine: Improve isGenerator accuracy * Fix redux-routine unit tests
- Loading branch information
1 parent
38378c8
commit 1949e3a
Showing
18 changed files
with
592 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { applyMiddleware } from 'redux'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import createMiddleware from '@wordpress/redux-routine'; | ||
|
||
export default function( registry ) { | ||
return { | ||
registerStore( reducerKey, options ) { | ||
const store = registry.registerStore( reducerKey, options ); | ||
|
||
if ( options.controls ) { | ||
const middleware = createMiddleware( options.controls ); | ||
const enhancer = applyMiddleware( middleware ); | ||
const createStore = () => store; | ||
|
||
Object.assign( | ||
store, | ||
enhancer( createStore )( options.reducer ) | ||
); | ||
} | ||
|
||
return store; | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { default as controls } from './controls'; | ||
export { default as persistence } from './persistence'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock=false |
Oops, something went wrong.