2024-11-18 18:58:54 +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 17:21:09 +01:00
const getState = ( state ) => state || EMPTY _OBJ ;
2024-11-18 18:58:54 +01:00
2024-11-20 17:21:09 +01:00
export const persistentData = ( state ) => {
2024-11-18 18:58:54 +01:00
return getState ( state ) . data || EMPTY _OBJ ;
} ;
2024-11-20 17:21:09 +01:00
export const transientData = ( state ) => {
2024-12-03 15:24:49 -04:00
const { data , wooSettings , ... transientState } = getState ( state ) ; // ← extract the wooSettings, to ensure they are not part of the "transientState" collection.
2024-11-18 18:58:54 +01:00
return transientState || EMPTY _OBJ ;
} ;
2024-12-03 15:24:49 -04:00
export const wooSettings = ( state ) => {
return getState ( state ) . wooSettings || EMPTY _OBJ ;
} ;