woocommerce-paypal-payments/modules/ppcp-settings/resources/js/data/onboarding/selectors.js

26 lines
660 B
JavaScript
Raw Normal View History

2024-11-18 18:51:11 +01:00
/**
* Selectors: Extract specific pieces of state from the store.
*
* These functions provide a consistent interface for accessing store data.
* They allow components to retrieve data without knowing the store structure.
*
* @file
*/
const EMPTY_OBJ = Object.freeze( {} );
2024-11-20 16:54:11 +01:00
const getState = ( state ) => state || EMPTY_OBJ;
2024-11-20 16:54:11 +01:00
export const persistentData = ( state ) => {
2024-11-18 16:25:57 +01:00
return getState( state ).data || EMPTY_OBJ;
};
2024-11-20 16:54:11 +01:00
export const transientData = ( state ) => {
2024-11-18 16:25:57 +01:00
const { data, flags, ...transientState } = getState( state );
return transientState || EMPTY_OBJ;
2024-10-22 18:56:37 +02:00
};
2024-11-20 16:54:11 +01:00
export const flags = ( state ) => {
2024-11-18 16:25:57 +01:00
return getState( state ).flags || EMPTY_OBJ;
};