File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,6 +4,27 @@ import { EndpointSchemas } from './core';
44import { GenerateEndpoints , generateEndpoints } from './generators' ;
55import { EndpointInvoker } from './invoker' ;
66
7+ /**
8+ * Convenience function that generates invocable endpoint functions
9+ * from the given endpoint schemas.
10+ *
11+ * @see `generateEndpoints` - for manually generating endpoints
12+ *
13+ * @example
14+ * ```ts
15+ * export const USER_ENDPOINTS = {
16+ * // ...
17+ * } as const satisfies EndpointSchemas;
18+ * ```
19+ * ```ts
20+ * private userEndpoints = useEndpoints(USER_ENDPOINTS);
21+ * ```
22+ */
23+ export const useEndpoints = < Schemas extends EndpointSchemas > (
24+ schemas : Schemas ,
25+ invoker = inject ( EndpointInvoker ) ,
26+ ) : GenerateEndpoints < Schemas > => generateEndpoints ( invoker , schemas ) ;
27+
728/**
829 * Convenience function that creates a typed `InjectionToken` with a default
930 * value of a collection of endpoints generated from the given schemas,
You can’t perform that action at this time.
0 commit comments