Skip to content

Commit 92a47ef

Browse files
flensrockerrainerhahnekamp
authored andcommitted
misc: refactored named types of withCallState
1 parent 4ea4328 commit 92a47ef

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

libs/ngrx-toolkit/src/lib/with-call-state.ts

+7-11
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,24 @@ import { Emtpy } from './shared/empty';
99

1010
export type CallState = 'init' | 'loading' | 'loaded' | { error: string };
1111

12-
export type NamedCallStateSlice<Collection extends string> = {
13-
[K in Collection as `${K}CallState`]: CallState;
14-
};
15-
1612
export type CallStateSlice = {
1713
callState: CallState
1814
}
1915

20-
export type NamedCallStateSignals<Prop extends string> = {
21-
[K in Prop as `${K}Loading`]: Signal<boolean>;
22-
} & {
23-
[K in Prop as `${K}Loaded`]: Signal<boolean>;
24-
} & {
25-
[K in Prop as `${K}Error`]: Signal<string | null>;
26-
}
16+
export type NamedCallStateSlice<Collection extends string> = {
17+
[K in keyof CallStateSlice as `${Collection}${Capitalize<K>}`]: CallStateSlice[K];
18+
}
2719

2820
export type CallStateSignals = {
2921
loading: Signal<boolean>;
3022
loaded: Signal<boolean>;
3123
error: Signal<string | null>
3224
}
3325

26+
export type NamedCallStateSignals<Prop extends string> = {
27+
[K in keyof CallStateSignals as `${Prop}${Capitalize<K>}`]: CallStateSignals[K];
28+
}
29+
3430
export type SetCallState<Prop extends string | undefined> = Prop extends string
3531
? NamedCallStateSlice<Prop>
3632
: CallStateSlice;

0 commit comments

Comments
 (0)