Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit 6bfe759

Browse files
author
Je
committed
refactor: rewrite useEnv hook
1 parent 180b6b8 commit 6bfe759

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

hooks.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ export function useDeno<T = any>(callback: () => (T | Promise<T>), browser?: boo
5353
return data
5454
}
5555

56-
export function useEnv(): AlephEnv {
57-
return useDeno<AlephEnv>(() => {
58-
return (globalThis as any).ALEPH.ENV
56+
export function useEnv<T>(predicate: (env: AlephEnv) => T): T {
57+
const env = useDeno<T>(() => {
58+
return predicate((globalThis as any).ALEPH.ENV)
5959
})
60+
return env
6061
}

0 commit comments

Comments
 (0)