-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: movel types for each trait to a .model.ts file
- Loading branch information
1 parent
b67f00c
commit db372bd
Showing
26 changed files
with
573 additions
and
503 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,28 @@ | ||
export * from './util'; | ||
export * from './with-call-status/with-call-status'; | ||
export * from './with-call-status/with-call-status.model'; | ||
export * from './with-entities-filter/with-entities-local-filter'; | ||
export * from './with-entities-filter/with-entities-local-filter.model'; | ||
export * from './with-entities-filter/with-entities-remote-filter'; | ||
export * from './with-entities-pagination/with-entities-local-pagination'; | ||
export * from './with-entities-pagination/with-entities-local-pagination.model'; | ||
export * from './with-entities-pagination/with-entities-remote-pagination'; | ||
export * from './with-entities-pagination/with-entities-remote-pagination.model'; | ||
export * from './with-entities-pagination/with-entities-remote-scroll-pagination'; | ||
export * from './with-entities-pagination/with-entities-remote-scroll-pagination.model'; | ||
export * from './with-entities-pagination/signal-infinite-datasource'; | ||
export { | ||
Sort, | ||
SortDirection, | ||
} from './with-entities-sort/with-entities-sort.utils'; | ||
export * from './with-entities-sort/with-entities-local-sort'; | ||
export * from './with-entities-sort/with-entities-local-sort.model'; | ||
export * from './with-entities-sort/with-entities-remote-sort'; | ||
export * from './with-entities-selection/with-entities-single-selection'; | ||
export * from './with-entities-selection/with-entities-single-selection.model'; | ||
export * from './with-entities-selection/with-entities-multi-selection'; | ||
export * from './with-entities-selection/with-entities-multi-selection.model'; | ||
export * from './with-entities-loading-call/with-entities-loading-call'; | ||
export * from './with-logger/with-logger'; | ||
export * from './with-calls/with-calls'; | ||
export * from './with-calls/with-calls.model'; | ||
export * from './with-sync-to-web-storage/with-sync-to-web-storage'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
libs/ngrx-traits/signals/src/lib/with-call-status/with-call-status.model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Signal } from '@angular/core'; | ||
|
||
export type CallStatus = 'init' | 'loading' | 'loaded' | { error: unknown }; | ||
export type CallStatusState = { | ||
callStatus: CallStatus; | ||
}; | ||
export type CallStatusComputed = { | ||
isLoading: Signal<boolean>; | ||
} & { | ||
isLoaded: Signal<boolean>; | ||
} & { | ||
error: Signal<string | null>; | ||
}; | ||
export type CallStatusMethods = { | ||
setLoading: () => void; | ||
} & { | ||
setLoaded: () => void; | ||
} & { | ||
setError: (error?: unknown) => void; | ||
}; | ||
export type NamedCallStatusState<Prop extends string> = { | ||
[K in Prop as `${K}CallStatus`]: CallStatus; | ||
}; | ||
export type NamedCallStatusComputed<Prop extends string> = { | ||
[K in Prop as `is${Capitalize<string & K>}Loading`]: Signal<boolean>; | ||
} & { | ||
[K in Prop as `is${Capitalize<string & K>}Loaded`]: Signal<boolean>; | ||
} & { | ||
[K in Prop as `${K}Error`]: Signal<string | null>; | ||
}; | ||
export type NamedCallStatusMethods<Prop extends string> = { | ||
[K in Prop as `set${Capitalize<string & K>}Loading`]: () => void; | ||
} & { | ||
[K in Prop as `set${Capitalize<string & K>}Loaded`]: () => void; | ||
} & { | ||
[K in Prop as `set${Capitalize<string & K>}Error`]: (error?: unknown) => void; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
libs/ngrx-traits/signals/src/lib/with-calls/with-calls.model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Observable } from 'rxjs'; | ||
|
||
export type Call<Params extends readonly any[] = any[], Result = any> = ( | ||
...args: Params | ||
) => Observable<Result> | Promise<Result>; | ||
export type CallConfig< | ||
Params extends readonly any[] = any[], | ||
Result = any, | ||
PropName extends string = string, | ||
> = { | ||
call: Call<Params, Result>; | ||
resultProp?: PropName; | ||
mapPipe?: 'switchMap' | 'concatMap' | 'exhaustMap'; | ||
}; | ||
export type ExtractCallResultType<T extends Call | CallConfig> = | ||
T extends Call<any, infer R> | ||
? R | ||
: T extends CallConfig<any, infer R> | ||
? R | ||
: never; | ||
export type ExtractCallParams<T extends Call | CallConfig> = | ||
T extends Call<infer P> ? P : T extends CallConfig<infer P> ? P : never; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
libs/ngrx-traits/signals/src/lib/with-entities-filter/with-entities-local-filter.model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Signal } from '@angular/core'; | ||
|
||
export type EntitiesFilterState<Filter> = { entitiesFilter: Filter }; | ||
export type NamedEntitiesFilterState<Collection extends string, Filter> = { | ||
[K in Collection as `${K}Filter`]: Filter; | ||
}; | ||
export type EntitiesFilterComputed = { | ||
isEntitiesFilterChanged: Signal<boolean>; | ||
}; | ||
export type NamedEntitiesFilterComputed<Collection extends string> = { | ||
[K in Collection as `is${Capitalize<string & K>}FilterChanged`]: Signal<boolean>; | ||
}; | ||
export type EntitiesFilterMethods<Filter> = { | ||
filterEntities: ( | ||
options: | ||
| { | ||
filter: Filter; | ||
debounce?: number; | ||
patch?: false | undefined; | ||
forceLoad?: boolean; | ||
} | ||
| { | ||
filter: Partial<Filter>; | ||
debounce?: number; | ||
patch: true; | ||
forceLoad?: boolean; | ||
}, | ||
) => void; | ||
resetEntitiesFilter: () => void; | ||
}; | ||
export type NamedEntitiesFilterMethods<Collection extends string, Filter> = { | ||
[K in Collection as `filter${Capitalize<string & K>}Entities`]: ( | ||
options: | ||
| { | ||
filter: Filter; | ||
debounce?: number; | ||
patch?: false | undefined; | ||
forceLoad?: boolean; | ||
} | ||
| { | ||
filter: Partial<Filter>; | ||
debounce?: number; | ||
patch: true; | ||
forceLoad?: boolean; | ||
}, | ||
) => void; | ||
} & { | ||
[K in Collection as `reset${Capitalize<string & K>}Filter`]: () => void; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.