-
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.
Refactor: move
core/edit-post
INIT effect to use action-generators …
…and controls (#14740) * move constants into constants file * move init effect into action-generators and controls * add tests for new functionality * update docs build * update changelog * clarify controls/actions that are experimental/unstable This leaves room for future refactors that could eliminate these. * fix reference for version in changelog * move dispatch of initialize action to initializeEditor execution * add js docs for constants * doc change * Add flag for triggering initial invoking of listener props @aduth * eliminate ADJUST_SIDEBAR control and move logic into action * update tests * update docs
- Loading branch information
Showing
10 changed files
with
335 additions
and
78 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
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,11 @@ | ||
/** | ||
* The identifier for the data store. | ||
* @type {string} | ||
*/ | ||
export const STORE_KEY = 'core/edit-post'; | ||
|
||
/** | ||
* CSS selector string for the admin bar view post link anchor tag. | ||
* @type {string} | ||
*/ | ||
export const VIEW_AS_LINK_SELECTOR = '#wp-admin-bar-view a'; |
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,48 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { createRegistryControl } from '@wordpress/data'; | ||
|
||
/** | ||
* Calls a selector using the current state. | ||
* | ||
* @param {string} storeName Store name. | ||
* @param {string} selectorName Selector name. | ||
* @param {Array} args Selector arguments. | ||
* | ||
* @return {Object} control descriptor. | ||
*/ | ||
export function select( storeName, selectorName, ...args ) { | ||
return { | ||
type: 'SELECT', | ||
storeName, | ||
selectorName, | ||
args, | ||
}; | ||
} | ||
|
||
/** | ||
* Calls a subscriber using the current state. | ||
* | ||
* @param {function} listenerCallback A callback for the subscriber that | ||
* receives the registry. | ||
* @return {Object} control descriptor. | ||
*/ | ||
export function __unstableSubscribe( listenerCallback ) { | ||
return { type: 'SUBSCRIBE', listenerCallback }; | ||
} | ||
|
||
const controls = { | ||
SELECT: createRegistryControl( | ||
( registry ) => ( { storeName, selectorName, args } ) => { | ||
return registry.select( storeName )[ selectorName ]( ...args ); | ||
} | ||
), | ||
SUBSCRIBE: createRegistryControl( | ||
( registry ) => ( { listenerCallback } ) => { | ||
return registry.subscribe( listenerCallback( registry ) ); | ||
} | ||
), | ||
}; | ||
|
||
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
Oops, something went wrong.