First store-refresh action in payment store

This commit is contained in:
Philipp Stracker 2025-02-14 17:45:31 +01:00
parent 838fd6a1a0
commit 3f5f587e88
No known key found for this signature in database
2 changed files with 15 additions and 1 deletions

View file

@ -94,3 +94,16 @@ export function persist() {
} );
};
}
/**
* Thunk action creator. Forces a data refresh from the REST API, replacing the current Redux values.
*
* @return {Function} The thunk function.
*/
export function refresh() {
return ( { dispatch, select } ) => {
dispatch.invalidateResolutionForStoreSelector( 'persistentData' );
select.persistentData();
};
}

View file

@ -102,11 +102,12 @@ const useHooks = () => {
export const useStore = () => {
const { useTransient, dispatch } = useStoreData();
const { persist, setPersistent, changePaymentSettings } = dispatch;
const { persist, refresh, setPersistent, changePaymentSettings } = dispatch;
const [ isReady ] = useTransient( 'isReady' );
return {
persist,
refresh,
setPersistent,
changePaymentSettings,
isReady,