mirror of
https://github.com/apricote/Listory.git
synced 2026-02-06 17:57:03 +00:00
feat: implement long-lived sessions
This commit is contained in:
parent
d0705afca8
commit
44f7e26270
35 changed files with 739 additions and 190 deletions
|
|
@ -3,7 +3,12 @@ import { useCallback, useEffect, useState } from "react";
|
|||
type UseAsync = <T>(
|
||||
asyncFunction: () => Promise<T>,
|
||||
initialValue: T
|
||||
) => { pending: boolean; value: T; error: Error | null };
|
||||
) => {
|
||||
pending: boolean;
|
||||
value: T;
|
||||
error: Error | null;
|
||||
reload: () => Promise<void>;
|
||||
};
|
||||
|
||||
export const useAsync: UseAsync = <T extends any>(
|
||||
asyncFunction: () => Promise<T>,
|
||||
|
|
@ -34,5 +39,5 @@ export const useAsync: UseAsync = <T extends any>(
|
|||
execute();
|
||||
}, [execute]);
|
||||
|
||||
return { execute, pending, value, error };
|
||||
return { reload: execute, pending, value, error };
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue