|
|
@@ -34,7 +34,7 @@ export function useStaticSWR<Data, Error>(
|
|
|
const ADVANCE_DELAY_MS = 800;
|
|
|
|
|
|
export type ITermNumberManagerUtil = {
|
|
|
- advance(): void,
|
|
|
+ advance(): Promise<void> | void,
|
|
|
}
|
|
|
|
|
|
export const useTermNumberManager = (key: Key) : SWRResponse<number, Error> & ITermNumberManagerUtil => {
|
|
|
@@ -42,15 +42,18 @@ export const useTermNumberManager = (key: Key) : SWRResponse<number, Error> & IT
|
|
|
|
|
|
return {
|
|
|
...swrResult,
|
|
|
- advance: () => {
|
|
|
+ advance: async() => {
|
|
|
const { data: currentNum } = swrResult;
|
|
|
if (currentNum == null) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- setTimeout(() => {
|
|
|
- swrResult.mutate(currentNum + 1);
|
|
|
- }, ADVANCE_DELAY_MS);
|
|
|
+ await new Promise((r) => {
|
|
|
+ setTimeout(async() => {
|
|
|
+ await swrResult.mutate(currentNum + 1);
|
|
|
+ r(null);
|
|
|
+ }, ADVANCE_DELAY_MS);
|
|
|
+ });
|
|
|
},
|
|
|
};
|
|
|
};
|