Skip to content

Commit

Permalink
misc: refactored named types of withCallState
Browse files Browse the repository at this point in the history
  • Loading branch information
flensrocker authored and rainerhahnekamp committed Mar 15, 2024
1 parent 4ea4328 commit 92a47ef
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions libs/ngrx-toolkit/src/lib/with-call-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,24 @@ import { Emtpy } from './shared/empty';

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

export type NamedCallStateSlice<Collection extends string> = {
[K in Collection as `${K}CallState`]: CallState;
};

export type CallStateSlice = {
callState: CallState
}

export type NamedCallStateSignals<Prop extends string> = {
[K in Prop as `${K}Loading`]: Signal<boolean>;
} & {
[K in Prop as `${K}Loaded`]: Signal<boolean>;
} & {
[K in Prop as `${K}Error`]: Signal<string | null>;
}
export type NamedCallStateSlice<Collection extends string> = {
[K in keyof CallStateSlice as `${Collection}${Capitalize<K>}`]: CallStateSlice[K];
}

export type CallStateSignals = {
loading: Signal<boolean>;
loaded: Signal<boolean>;
error: Signal<string | null>
}

export type NamedCallStateSignals<Prop extends string> = {
[K in keyof CallStateSignals as `${Prop}${Capitalize<K>}`]: CallStateSignals[K];
}

export type SetCallState<Prop extends string | undefined> = Prop extends string
? NamedCallStateSlice<Prop>
: CallStateSlice;
Expand Down

0 comments on commit 92a47ef

Please sign in to comment.