{"id":18429614,"url":"https://github.com/qontu/component-store","last_synced_at":"2025-04-13T21:45:07.003Z","repository":{"id":128865573,"uuid":"151486934","full_name":"qontu/component-store","owner":"qontu","description":null,"archived":false,"fork":false,"pushed_at":"2019-03-10T12:05:09.000Z","size":137,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-16T08:43:25.204Z","etag":null,"topics":["angular","angular2","angular4","angular5","angular6","angular7","component","component-store","immer","redux","store"],"latest_commit_sha":null,"homepage":null,"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/qontu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-03T22:10:44.000Z","updated_at":"2019-03-10T12:04:40.000Z","dependencies_parsed_at":"2023-08-26T10:48:33.129Z","dependency_job_id":null,"html_url":"https://github.com/qontu/component-store","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qontu%2Fcomponent-store","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qontu%2Fcomponent-store/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qontu%2Fcomponent-store/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qontu%2Fcomponent-store/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qontu","download_url":"https://codeload.github.com/qontu/component-store/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248788869,"owners_count":21161726,"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":["angular","angular2","angular4","angular5","angular6","angular7","component","component-store","immer","redux","store"],"created_at":"2024-11-06T05:17:54.535Z","updated_at":"2025-04-13T21:45:06.972Z","avatar_url":"https://github.com/qontu.png","language":"TypeScript","readme":"# Component Store\n\nInspired (semi-forked) of https://github.com/amcdnl/ngrx-actions\n\nThe mission of this (another more... :laughing:) `store` is to maintain the state of a component (not the wide app).\n\nI have been searching for one and I didn't find any... then, I created it :sweat_smile:\n\n## Dependencies\n\nThis module depends on [immer](https://github.com/mweststrate/immer)\n\n## How to install?\n\n`npm i immer @qontu/component-store` or `yarn add immer @qontu/component-store`\n\n## How to use?\n\nYou can see an example [here](./playground/src/app/components/button)\n\n## Why do I need to install immer?\n\nBecause it's a powerful inmutable state tree, it allow us to do:\n\n```ts\ninterface UserListState {\n  users: User[],\n  usersMap: Record\u003cnumber, User\u003e,\n}\n\n\n@Store\u003cUserListState\u003e({\n  users: [],\n  usersMap: {},\n})\nexport class UserListStore {\n\n  @Action(Update)\n  updateUsingImmer(state: UserListState, { user  }: Update) {\n    const userToUpdate = state.users.find(({ id }) =\u003e id === user.id);\n    Object.assign(userToUpdate, user);\n  }\n\n  @Action(Update)\n  updateWithoutImmer(state: UserListState, { user  }: Update) {\n    return {\n      ...state,\n      users: [\n        ...state.users.filter(({ id }) =\u003e id !== user.id),\n        user,\n      ]\n    }\n  }\n\n  // Update an object-map\n\n  @Action(Update)\n  updateUsingImmer(state: UserListState, { user  }: Update) {\n    state.usersMap[user.id] = user;\n  }\n\n  @Action(Update)\n  updateWithoutImmer(state: UserListState, { user  }: Update) {\n    return {\n      ...state,\n      usersMap: [\n        ...state.usersMap,\n        [user.id]: user,\n      ]\n    }\n  }\n}\n```\n\nyou can use both in the same time, choose the one that you prefer :smile:\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqontu%2Fcomponent-store","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqontu%2Fcomponent-store","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqontu%2Fcomponent-store/lists"}