-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the selectors/controls to use the registry selectors/controls
- Loading branch information
1 parent
7f3182c
commit 9967510
Showing
5 changed files
with
56 additions
and
32 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
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,29 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { createRegistryControl } from '@wordpress/data'; | ||
|
||
/** | ||
* Calls a selector using the current state. | ||
* @param {string} storeKey Store key. | ||
* @param {string} actionName Action name. | ||
* @param {Array} args Action arguments. | ||
* | ||
* @return {Object} control descriptor. | ||
*/ | ||
export function dispatch( storeKey, actionName, ...args ) { | ||
return { | ||
type: 'DISPATCH', | ||
storeKey, | ||
actionName, | ||
args, | ||
}; | ||
} | ||
|
||
const controls = { | ||
DISPATCH: createRegistryControl( ( registry ) => ( { storeKey, actionName, args } ) => { | ||
return registry.dispatch( storeKey )[ actionName ]( ...args ); | ||
} ), | ||
}; | ||
|
||
export default controls; |
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