{"id":24727023,"url":"https://github.com/js-smart/ng-store","last_synced_at":"2025-10-09T21:32:04.115Z","repository":{"id":218454730,"uuid":"746442014","full_name":"js-smart/ng-store","owner":"js-smart","description":"A simple store built with Angular signals","archived":true,"fork":false,"pushed_at":"2025-08-11T15:00:56.000Z","size":276,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-12T07:32:16.033Z","etag":null,"topics":["angular","signals","typescript"],"latest_commit_sha":null,"homepage":"https://stackblitz.com/~/github.com/js-smart/ng-store","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/js-smart.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":"FUNDING.yml","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},"funding":{"open_collective":"ngxsmart"}},"created_at":"2024-01-22T02:00:15.000Z","updated_at":"2025-08-11T15:01:10.000Z","dependencies_parsed_at":"2024-01-22T03:31:17.658Z","dependency_job_id":"692a8a2a-75d0-493d-9a2d-4fe1d11a3a90","html_url":"https://github.com/js-smart/ng-store","commit_stats":null,"previous_names":["js-smart/ng-store"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/js-smart/ng-store","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/js-smart%2Fng-store","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/js-smart%2Fng-store/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/js-smart%2Fng-store/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/js-smart%2Fng-store/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/js-smart","download_url":"https://codeload.github.com/js-smart/ng-store/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/js-smart%2Fng-store/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279002051,"owners_count":26083286,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","signals","typescript"],"created_at":"2025-01-27T14:42:55.571Z","updated_at":"2025-10-09T21:32:04.106Z","avatar_url":"https://github.com/js-smart.png","language":"TypeScript","readme":"# NG Store\n\u003e ### 📝 Important: This package has been migrated to [@js-smart/ng-kit](https://github.com/js-smart/ng-kit/tree/main/projects/ng-kit/src/lib/store) and this repo has been archived \n\n\n\nA simple store built with Angular signals. The state information can be stored in `Store` and entities can be stored in `EntityStore`.\nThe `Store` and `EntityStore` are built with Angular signals\n\n## Installation\nInstall the library\n```shell\nnpm install @js-smart/ng-store\n```\n\n## Usage\n### Store\nTo use the Store, create store service and provide correct type. This brings `update` method from Store and data can be updated using this method\n\n**login-store.service.ts**\n```typescript\nimport { Store } from '@js-smart/ng-store';\nimport { Injectable } from '@angular/core';\n\nexport interface LoginState {\n  isLoggedIn: boolean;\n  userName: string;\n}\n\n@Injectable({\n\tprovidedIn: 'root',\n})\nexport class LoginStore extends Store\u003cLoginState\u003e {\n\tconstructor() {\n\t\tsuper();\n\t}\n}\n```\n**login.component.ts**\nAnd inject the store in the component and use `update` method to update the state and `data` property to get the state\n```typescript\nimport { LoginStore } from './login-store.service';\nimport { Component, inject } from '@angular/core';\n\n@Component({\n  selector: 'app-login',\n  templateUrl: './login.component.html',\n})\nexport class LoginComponent {\n  loginStore = inject(LoginStore);\n  loginState = this.loginStore.data;\n\n  login() {\n    this.loginStore.update({ isLoggedIn: true, userName: 'John Doe' });\n  }\n\n  logout() {\n    this.loginStore.update({ isLoggedIn: false, userName: '' });\n  }\n}\n```\n\n### Entity Store\nTo use the Entity Store, create store service and provide correct type. This brings `findById`, `set`, `upsert`,`upsertMulti` and `remove` methods from Entity Store and data can be updated using these methods\n\n**employee-store.service.ts**\n```typescript\nimport { Store } from '@js-smart/ng-store';\nimport { Injectable } from '@angular/core';\n\nexport interface Employee {\n  id: number;\n  firstName: string;\n  lastName: string;\n  email: string;\n  phone: string;\n  age: number;\n}\n\n@Injectable({\n  providedIn: 'root',\n})\nexport class EmployeeStore extends EntityStore\u003cEmployee\u003e {\n  constructor() {\n    super();\n  }\n}\n```\n**employee.component.ts**\nAnd inject the store in the component and use `set` method to update the state and `data` property to get the state\n```typescript\nimport { LoginStore } from './login-store.service';\nimport { Component, inject,OnInit } from '@angular/core';\n\n@Component({\n  selector: 'app-login',\n  templateUrl: './login.component.html',\n})\nexport class LoginComponent implements OnInit {\n  employeeService = inject(EmployeeService);\n  employeeStore = inject(EmployeeStore);\n\n  ngOnInit(): void {\n    this.employeeService.getEmployees().subscribe((employees) =\u003e {\n      this.employeeStore.set(employees);\n    });\n  }\n}\n```\n\n## Demo\n1. Run `npm run start` to start the demo project\n2. Open `http://localhost:4300` in your browser\n\n## Running unit tests\nRun `ng test` to execute the unit tests\n","funding_links":["https://opencollective.com/ngxsmart"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjs-smart%2Fng-store","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjs-smart%2Fng-store","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjs-smart%2Fng-store/lists"}