mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
🧑💻 Add simple filter-callback for dumpStore
This commit is contained in:
parent
e5f83756ab
commit
b9785d1705
1 changed files with 13 additions and 5 deletions
|
@ -26,7 +26,7 @@ export const addDebugTools = ( context, modules ) => {
|
||||||
const debugApi = ( window.ppcpDebugger = window.ppcpDebugger || {} );
|
const debugApi = ( window.ppcpDebugger = window.ppcpDebugger || {} );
|
||||||
|
|
||||||
// Dump the current state of all our Redux stores.
|
// Dump the current state of all our Redux stores.
|
||||||
debugApi.dumpStore = async () => {
|
debugApi.dumpStore = async ( cbFilter = null ) => {
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
if ( ! console?.groupCollapsed ) {
|
if ( ! console?.groupCollapsed ) {
|
||||||
console.error( 'console.groupCollapsed is not supported.' );
|
console.error( 'console.groupCollapsed is not supported.' );
|
||||||
|
@ -39,11 +39,19 @@ export const addDebugTools = ( context, modules ) => {
|
||||||
console.group( `[STORE] ${ storeSelector }` );
|
console.group( `[STORE] ${ storeSelector }` );
|
||||||
|
|
||||||
const dumpStore = ( selector ) => {
|
const dumpStore = ( selector ) => {
|
||||||
const contents = wp.data.select( storeName )[ selector ]();
|
let contents = wp.data.select( storeName )[ selector ]();
|
||||||
|
|
||||||
console.groupCollapsed( `.${ selector }()` );
|
if ( cbFilter ) {
|
||||||
console.table( contents );
|
contents = cbFilter( contents, selector, storeName );
|
||||||
console.groupEnd();
|
|
||||||
|
if ( undefined !== contents && null !== contents ) {
|
||||||
|
console.log( `.${ selector }() [filtered]`, contents );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.groupCollapsed( `.${ selector }()` );
|
||||||
|
console.table( contents );
|
||||||
|
console.groupEnd();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.keys( module.selectors ).forEach( dumpStore );
|
Object.keys( module.selectors ).forEach( dumpStore );
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue