Skip to content

Commit

Permalink
added prefetch for getCountries as well
Browse files Browse the repository at this point in the history
  • Loading branch information
rjchow committed May 12, 2023
1 parent c5d9f01 commit 8f14774
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion plugins/woocommerce-admin/client/core-profiler/index.tsx
Expand Up @@ -106,6 +106,17 @@ const handleTrackingOption = assign( {
) => event.data !== 'no',
} );

/**
* Prefetch it so that @wp/data caches it and there won't be a loading delay when its used
*/
const preFetchGetCountries = assign( {
spawnGetCountriesRef: () =>
spawn(
resolveSelect( COUNTRIES_STORE_NAME ).getCountries(),
'core-profiler-prefetch-countries'
),
} );

const getCountries = async () =>
resolveSelect( COUNTRIES_STORE_NAME ).getCountries();

Expand Down Expand Up @@ -221,6 +232,7 @@ const handleExtensions = assign( {
const coreProfilerMachineActions = {
updateTrackingOption,
preFetchGetExtensions,
preFetchGetCountries,
handleTrackingOption,
handleExtensions,
recordTracksIntroCompleted,
Expand Down Expand Up @@ -261,7 +273,7 @@ export const coreProfilerStateMachineDefinition = createMachine( {
target: 'introOptIn',
},
},
entry: [ 'preFetchGetExtensions' ],
entry: [ 'preFetchGetExtensions', 'preFetchGetCountries' ],
invoke: [
{
src: 'getAllowTrackingOption',
Expand Down

0 comments on commit 8f14774

Please sign in to comment.