Skip to content

Commit 13840ed

Browse files
committed
Update getConfig resolver
1 parent 8f1f572 commit 13840ed

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

projects/packages/forms/src/store/config/resolvers.ts

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,22 @@ const fetchConfigData = async ( dispatch: ( action: ConfigAction ) => void ) =>
2020
}
2121
};
2222

23-
export const getConfig = {
24-
fulfill:
25-
() =>
26-
async ( { dispatch }: { dispatch: ( action: ConfigAction ) => void } ) => {
27-
await fetchConfigData( dispatch );
28-
},
29-
isFulfilled: ( state: ConfigState ) => {
30-
// Consider fulfilled if config exists or is currently loading
31-
return state.config !== null || state.isLoading;
32-
},
33-
shouldInvalidate: ( action: ConfigAction ) => {
34-
return action.type === INVALIDATE_CONFIG;
35-
},
23+
/**
24+
* Resolver to fetch config data.
25+
*
26+
* @return {Function} The resolver function.
27+
*/
28+
export function getConfig() {
29+
return async ( { dispatch }: { dispatch: ( action: ConfigAction ) => void } ) => {
30+
await fetchConfigData( dispatch );
31+
};
32+
}
33+
34+
getConfig.isFulfilled = ( state: ConfigState ) => {
35+
// Consider fulfilled if config exists or is currently loading
36+
return state.config !== null || state.isLoading;
37+
};
38+
39+
getConfig.shouldInvalidate = ( action: ConfigAction ) => {
40+
return action.type === INVALIDATE_CONFIG;
3641
};

0 commit comments

Comments
 (0)