mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
✨ First store-refresh action in payment store
This commit is contained in:
parent
838fd6a1a0
commit
3f5f587e88
2 changed files with 15 additions and 1 deletions
|
@ -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();
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue