{"id":21944238,"url":"https://github.com/michaelkrone/ngrx-normalizr-crud","last_synced_at":"2025-04-22T21:05:47.780Z","repository":{"id":65458353,"uuid":"103709071","full_name":"michaelkrone/ngrx-normalizr-crud","owner":"michaelkrone","description":"CRUD reducer, actions, selectors and effects for ngrx-normalizr states","archived":false,"fork":false,"pushed_at":"2018-02-20T19:19:21.000Z","size":239,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-22T21:05:42.893Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://michaelkrone.github.io/ngrx-normalizr-crud/.","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/michaelkrone.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-15T23:16:24.000Z","updated_at":"2017-10-25T08:43:59.000Z","dependencies_parsed_at":"2023-01-24T13:15:32.463Z","dependency_job_id":null,"html_url":"https://github.com/michaelkrone/ngrx-normalizr-crud","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelkrone%2Fngrx-normalizr-crud","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelkrone%2Fngrx-normalizr-crud/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelkrone%2Fngrx-normalizr-crud/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelkrone%2Fngrx-normalizr-crud/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michaelkrone","download_url":"https://codeload.github.com/michaelkrone/ngrx-normalizr-crud/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250324692,"owners_count":21411946,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-29T04:15:11.626Z","updated_at":"2025-04-22T21:05:47.757Z","avatar_url":"https://github.com/michaelkrone.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WIP: ngrx-normalizr-crud\n\n[![Build Status](https://travis-ci.org/michaelkrone/ngrx-normalizr-crud.svg?branch=master)](https://travis-ci.org/michaelkrone/ngrx-normalizr-crud)\n![AOT compatible](https://img.shields.io/badge/aot-compatible-blue.svg)\n\n\u003e Actions, effects, reducers, selectors and guards for [ngrx-normalizr](https://github.com/michaelkrone/ngrx-normalizr).\n\nThis package provides a set of Actions, effects, reducers, selectors and guards for using [ngrx-normalizr](https://github.com/michaelkrone/ngrx-normalizr)\nentity states.\n\n## Installation\nTo install this package:\n```sh\nyarn add ngrx-normalizr-crud\nnpm i ngrx-normalizr-crud\n```\n\n### Peer dependencies\n*ngrx-normalizr-crud* uses `@ngrx/store` and `ngrx-normalizer` as peer dependencies, so you need to install them if not present already:\n\n```sh\nyarn add @ngrx/store ngrx-normalizer\nnpm i @ngrx/store ngrx-normalizer\n```\n## Usage\nAlso refer to the [Typedoc documentation](https://michaelkrone.github.io/ngrx-normalizr-crud/).\n\n##### reducer.ts\n```javascript\nimport { createReducer, NormalizedEntityState, initialEntityState } from 'ngrx-normalizr-crud';\n\nconst entityReducer = createReducer(userSchema);\n\nexport function reducer(\n\tstate: NormalizedEntityState = initialEntityState,\n\taction: any\n) {\n  // do any reducer logic for your state or in this case\n  // simply return the result of the entity reducer\n\treturn entityReducer(state, action);\n}\n```\n\n##### selectors\n```javascript\nimport { createSelectors } from 'ngrx-normalizr-crud';\nimport { User, userSchema } from '../classes/user';\n\n// create an entity state selector\nconst featureSelector = createFeatureSelector\u003cState\u003e('users');\nconst getUserEntityState = createSelector(\n  featureSelector,\n  (state: State) =\u003e state.userEntity\n);\n\nexport const entitySelectors = {\n  // pass the entity state selector\n  ...createSelectors\u003cUser\u003e(userSchema, getUserEntityState)\n};\n```\n##### actions.ts\n```javascript\nimport { createActions } from 'ngrx-normalizr-crud';\nimport { User, userSchema } from '../classes/user';\n\nexport const actions = createActions\u003cUser\u003e(userSchema);\n```\n\n##### effects.ts\n```javascript\nimport { EntityCrudEffect } from 'ngrx-normalizr-crud';\nimport { User, userSchema } from '../classes/user';\n\n@Injectable()\nexport class UserCrudEffects extends EntityCrudEffect\u003cUser\u003e {\n\n  constructor(private actions$: Actions, private http: HttpClient) {\n    super(actions$, userSchema);\n  }\n\n  // use createSearchEffect, createUpdateEffect ...\n  @Effect()\n\tsearchEffect$ = this.createSearchEffect(\n    action =\u003e this.http.get('/users')\n\t);\n\n  // ...\n}\n```\n\n## State properties\n```\nloading: boolean;\nselectedId: string;\nquery: any;\nerror: any;\n```\n\n## Selectors\n```\ngetSelectedId: MemoizedSelector\u003cobject, NormalizedEntityState['selectedId']\u003e;\ngetLoading: MemoizedSelector\u003cobject, NormalizedEntityState['loading']\u003e;\ngetIds: MemoizedSelector\u003cobject, NormalizedEntityState['selectedId'][]\u003e;\ngetQuery: MemoizedSelector\u003cobject, NormalizedEntityState['query']\u003e;\ngetError: MemoizedSelector\u003cobject, NormalizedEntityState['error']\u003e;\ngetEntities: MemoizedSelector\u003c{}, T[]\u003e;\ngetSelectedEntity: MemoizedSelector\u003cany, T\u003e;\n```\n## Meta\n\nMichael Krone – [@DevDig](https://twitter.com/DevDig) – michael.krone@outlook.com\n\nDistributed under the MIT license. See [``LICENSE``](https://github.com/michaelkrone/ngrx-normalizr-crud/blob/master/LICENSE) for more information.\n\n[https://github.com/michaelkrone/ngrx-normalizr](https://github.com/michaelkrone/ngrx-normalizr-crud)\n\n## Contributing\n\n1. Fork it (\u003chttps://github.com/michaelkrone/ngrx-normalizr-crud\u003e)\n2. Create your feature branch (`git checkout -b feature/fooBar`)\n3. Commit your changes (`git commit -am 'Add some fooBar'`)\n4. Push to the branch (`git push origin feature/fooBar`)\n5. Create a new [Pull Request](https://github.com/michaelkrone/ngrx-normalizr-crud/compare?expand=1)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelkrone%2Fngrx-normalizr-crud","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichaelkrone%2Fngrx-normalizr-crud","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelkrone%2Fngrx-normalizr-crud/lists"}