WIP: ngrx-normalizr-crud
Actions, effects, reducers, selectors and guards for ngrx-normalizr.
This package provides a set of Actions, effects, reducers, selectors and guards for using ngrx-normalizr entity states.
Installation
To install this package:
yarn add ngrx-normalizr-crudnpm i ngrx-normalizr-crud
Peer dependencies
ngrx-normalizr-crud uses @ngrx/store
and ngrx-normalizer
as peer dependencies, so you need to install them if not present already:
yarn add @ngrx/store ngrx-normalizernpm i @ngrx/store ngrx-normalizer
Usage
Also refer to the Typedoc documentation.
reducer.ts
; const entityReducer = ; { // do any reducer logic for your state or in this case // simply return the result of the entity reducer return ;}
selectors
;; // create an entity state selectorconst featureSelector = createFeatureSelector<State>'users';const getUserEntityState = ; const entitySelectors = // pass the entity state selector ...createSelectors<User>userSchema getUserEntityState;
actions.ts
;; const actions = createActions<User>userSchema;
effects.ts
;; @<User> { superactions$ userSchema; } // use createSearchEffect, createUpdateEffect ... @ searchEffect$ = this; // ...
State properties
loading: boolean;
selectedId: string;
query: any;
error: any;
Selectors
getSelectedId: MemoizedSelector<object, NormalizedEntityState['selectedId']>;
getLoading: MemoizedSelector<object, NormalizedEntityState['loading']>;
getIds: MemoizedSelector<object, NormalizedEntityState['selectedId'][]>;
getQuery: MemoizedSelector<object, NormalizedEntityState['query']>;
getError: MemoizedSelector<object, NormalizedEntityState['error']>;
getEntities: MemoizedSelector<{}, T[]>;
getSelectedEntity: MemoizedSelector<any, T>;
Meta
Michael Krone – @DevDig – michael.krone@outlook.com
Distributed under the MIT license. See LICENSE
for more information.
https://github.com/michaelkrone/ngrx-normalizr
Contributing
- Fork it (https://github.com/michaelkrone/ngrx-normalizr-crud)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request