UNPKG

alepha

Version:

Easy-to-use modern TypeScript framework for building many kind of applications.

13 lines (11 loc) 392 B
import type { Service } from "alepha"; import { useMemo } from "react"; import { useAlepha } from "./useAlepha.ts"; /** * Hook to inject a service instance. * It's a wrapper of `useAlepha().inject(service)` with a memoization. */ export const useInject = <T extends object>(service: Service<T>): T => { const alepha = useAlepha(); return useMemo(() => alepha.inject(service), []); };