Skip to content
This repository was archived by the owner on Nov 2, 2023. It is now read-only.

Commit f490e3e

Browse files
committed
fix: refreshing a react component returns now a promise
1 parent b5cf71f commit f490e3e

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

core/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export interface EndpointGetFunction<TKeys extends {}, TResult extends unknown>
7474
/**
7575
* Clear the cache for this url
7676
*/
77-
refresh: () => void;
77+
refresh: () => Promise<any[]>;
7878
/**
7979
* Cache Key
8080
*/

core/src/lib/CacheStore.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export interface CacheStore<TKeys, TResult> {
1717
/**
1818
* Clear the cache for this url
1919
*/
20-
refresh: () => void;
20+
refresh: () => Promise<any[]>;
2121
/**
2222
* Cache Key
2323
*/
@@ -165,7 +165,7 @@ export function createCacheStore<
165165
*/
166166
observe: function(
167167
keys: TKeys,
168-
callback: (result: TResult) => any,
168+
callback: (result: TResult) => Promise<any>,
169169
timeout?: number
170170
) {
171171
let latestPromise: Promise<TResult> | undefined;

utils/request-registry-react/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,12 @@ export function useGetEndPoint<TEndpoint extends EndpointGetFunction<any, any>>(
5555
// Track this hook as endpoint consumer
5656
// once all consumers are gone the memory will be freed
5757
return endpoint.observePromise(latestKeys.current, () => {
58+
const result = executeEndpoint();
5859
updateEndpointState({
5960
type: "executeAjax",
6061
promise: executeEndpoint()
6162
});
63+
return result;
6264
});
6365
}, [endpoint, endpoint.getCacheKey(keys)]);
6466
return endpointState;

0 commit comments

Comments
 (0)