Skip to content

Commit

Permalink
fix(actions, selectors): Fixed typings that made actions and selector…
Browse files Browse the repository at this point in the history
…s unexistent not throw an compile error
  • Loading branch information
Gabriel Guerrero authored and gabrielguerrero committed Mar 3, 2022
1 parent 04569a9 commit 36f7549
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,7 @@ export class ProductBasketTabComponent {
}

sortBasket(sort: Sort<Product>) {
this.store.dispatch(
// TODO fix here no errors on worng name
// ProductBasketActions.FIXTTHISNOTREDsortProductOrders(sort)
ProductBasketActions.sortProductOrders(sort)
);
this.store.dispatch(ProductBasketActions.sortProductOrders(sort));
}

remove() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ export class ProductShopTabComponent implements OnInit {
this.store.dispatch(ProductActions.loadProductDetail({ id }));
}

checkout() {
this.store.dispatch(ProductActions.checkout());
}

filter(filters: ProductFilter) {
this.store.dispatch(ProductActions.filterProducts({ filters }));
}
Expand Down
27 changes: 21 additions & 6 deletions libs/ngrx-traits/src/lib/create-entity-feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@ import {
TraitActionsFactoryConfig,
TraitFactory,
TraitSelectors,
TraitSelectorsFactoryConfig,
TraitStateMutators,
UnionToIntersection,
TraitActionsFactory,
TraitSelectorsFactory,
TraitInitialStateFactory,
TraitStateMutatorsFactory,
TraitReducerFactory,
TraitEffectsFactory,
} from './model';
import {
Action,
Expand All @@ -30,14 +35,24 @@ import { capitalize } from './util';

export function createTraitFactory<
State = {},
A extends TraitActions = TraitActions,
S extends TraitSelectors<State> = TraitSelectors<State>,
M extends TraitStateMutators<State> = TraitStateMutators<State>,
A extends TraitActions = {},
S extends TraitSelectors<State> = {},
M extends TraitStateMutators<State> = {},
KEY extends string = string,
C = unknown,
KC = KeyedConfig<KEY, C>
>(f: TraitFactory<State, A, S, M, KEY, C, KC>) {
return f;
>(f: {
key: KEY;
config?: C;
depends?: string[];
actions?: TraitActionsFactory<A, KC>;
selectors?: TraitSelectorsFactory<State, S, KC>;
initialState?: TraitInitialStateFactory<State, KC>;
mutators?: TraitStateMutatorsFactory<State, M, KC>;
reducer?: TraitReducerFactory<State, A, S, M, KC>;
effects?: TraitEffectsFactory<State, A, S, KC>;
}): TraitFactory<State, A, S, M, KEY, C, KC> {
return f as TraitFactory<State, A, S, M, KEY, C, KC>;
}

export function createEntityFeatureFactory<
Expand Down
8 changes: 4 additions & 4 deletions libs/ngrx-traits/src/lib/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ export interface TraitFactory<
key: KEY;
config?: C;
depends?: string[];
actions?: TraitActionsFactory<A, KC>;
selectors?: TraitSelectorsFactory<State, S, KC>;
initialState?: TraitInitialStateFactory<State, KC>;
mutators?: TraitStateMutatorsFactory<State, M, KC>;
actions: TraitActionsFactory<A, KC>;
selectors: TraitSelectorsFactory<State, S, KC>;
initialState: TraitInitialStateFactory<State, KC>;
mutators: TraitStateMutatorsFactory<State, M, KC>;
reducer?: TraitReducerFactory<State, A, S, M, KC>;
effects?: TraitEffectsFactory<State, A, S, KC>;
}
Expand Down

0 comments on commit 36f7549

Please sign in to comment.