Skip to content

Commit

Permalink
fix: allow combined service implementation resolvers usage (types)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wroud committed Nov 20, 2024
1 parent 06ae156 commit a85caa4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions packages/@wroud/di-react/src/useService.ts
Original file line number Diff line number Diff line change
@@ -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<T>(type: SingleServiceType<T>): T {
return useServiceIterator(single(type));
export function useService<T>(type: ServiceType<T>): T {
if (!isServiceTypeResolver(type)) {
type = single(type);
}
return useServiceIterator(type);
}
4 changes: 2 additions & 2 deletions packages/@wroud/di-react/src/useServices.ts
Original file line number Diff line number Diff line change
@@ -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<T>(type: SingleServiceType<T>): T[] {
export function useServices<T>(type: ServiceType<T>): T[] {
return useServiceIterator(all(type));
}

0 comments on commit a85caa4

Please sign in to comment.