diff --git a/packages/@wroud/di-react/src/useService.ts b/packages/@wroud/di-react/src/useService.ts index ccc85a3..d0b2130 100644 --- a/packages/@wroud/di-react/src/useService.ts +++ b/packages/@wroud/di-react/src/useService.ts @@ -1,7 +1,11 @@ -import type { SingleServiceType } from "@wroud/di/types"; +import type { ServiceType } from "@wroud/di/types"; import { useServiceIterator } from "./useServiceIterator.js"; import { single } from "@wroud/di"; +import { isServiceTypeResolver } from "@wroud/di/service-type-resolvers/BaseServiceTypeResolver.js"; -export function useService(type: SingleServiceType): T { - return useServiceIterator(single(type)); +export function useService(type: ServiceType): T { + if (!isServiceTypeResolver(type)) { + type = single(type); + } + return useServiceIterator(type); } diff --git a/packages/@wroud/di-react/src/useServices.ts b/packages/@wroud/di-react/src/useServices.ts index 0009aac..779bf1e 100644 --- a/packages/@wroud/di-react/src/useServices.ts +++ b/packages/@wroud/di-react/src/useServices.ts @@ -1,7 +1,7 @@ -import type { SingleServiceType } from "@wroud/di/types"; +import type { ServiceType } from "@wroud/di/types"; import { useServiceIterator } from "./useServiceIterator.js"; import { all } from "@wroud/di"; -export function useServices(type: SingleServiceType): T[] { +export function useServices(type: ServiceType): T[] { return useServiceIterator(all(type)); }