{"id":26051008,"url":"https://github.com/tauhidul0821/angular-simple-store-by-signal","last_synced_at":"2026-04-20T11:33:15.871Z","repository":{"id":275981787,"uuid":"925453216","full_name":"tauhidul0821/angular-simple-store-by-signal","owner":"tauhidul0821","description":"Created with StackBlitz ⚡️ , Simple Store management by signal","archived":false,"fork":false,"pushed_at":"2025-02-05T16:28:46.000Z","size":65,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-08T03:36:51.317Z","etag":null,"topics":["angular","behaviorsubject","rxjs","signal","store"],"latest_commit_sha":null,"homepage":"https://stackblitz.com/~/github.com/tauhidul0821/angular-simple-store-by-signal","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tauhidul0821.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2025-01-31T23:00:51.000Z","updated_at":"2025-02-05T16:28:49.000Z","dependencies_parsed_at":"2025-02-05T16:43:47.850Z","dependency_job_id":"e347eca0-0a9b-4475-a084-d66ef58203bf","html_url":"https://github.com/tauhidul0821/angular-simple-store-by-signal","commit_stats":null,"previous_names":["tauhidul0821/angular-simple-store-by-signal"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tauhidul0821/angular-simple-store-by-signal","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tauhidul0821%2Fangular-simple-store-by-signal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tauhidul0821%2Fangular-simple-store-by-signal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tauhidul0821%2Fangular-simple-store-by-signal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tauhidul0821%2Fangular-simple-store-by-signal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tauhidul0821","download_url":"https://codeload.github.com/tauhidul0821/angular-simple-store-by-signal/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tauhidul0821%2Fangular-simple-store-by-signal/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32045327,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T10:33:29.490Z","status":"ssl_error","status_checked_at":"2026-04-20T10:32:30.107Z","response_time":94,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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","behaviorsubject","rxjs","signal","store"],"created_at":"2025-03-08T03:36:53.129Z","updated_at":"2026-04-20T11:33:15.854Z","avatar_url":"https://github.com/tauhidul0821.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# This is simple store management project using signal, rxjs, behavior subject\n\n### Step 1: Create the Service\n\n```ts\nimport { Injectable, signal } from \"@angular/core\";\n\n@Injectable({\n  providedIn: \"root\",\n})\nexport class StorageService {\n  private storage = signal\u003cRecord\u003cstring, any\u003e\u003e({}); // Central storage using signals\n\n  // Save data by key\n  save(key: string, value: any): void {\n    const currentData = this.storage();\n    this.storage.set({ ...currentData, [key]: value });\n  }\n\n  // Retrieve data by key\n  get(key: string): any {\n    return this.storage()[key];\n  }\n\n  // Delete data by key\n  remove(key: string): void {\n    const currentData = this.storage();\n    const { [key]: _, ...updatedData } = currentData; // Exclude the key to remove\n    this.storage.set(updatedData);\n  }\n\n  // Get all stored data (optional)\n  getAll(): Record\u003cstring, any\u003e {\n    return this.storage();\n  }\n}\n```\n\n### Step 2: Use the Service in Components\n\n```ts\nimport { Component } from \"@angular/core\";\nimport { StorageService } from \"./storage.service\";\n\n@Component({\n  selector: \"app-root\",\n  template: `\u003cbutton (click)=\"saveData()\"\u003eSave Data\u003c/button\u003e`,\n})\nexport class AppComponent {\n  constructor(private storageService: StorageService) {}\n\n  saveData() {\n    this.storageService.save(\"user\", { name: \"John\", age: 30 });\n    console.log(\"Data saved!\");\n  }\n}\n```\n\n### Retrieving Data\n\n```ts\nimport { Component } from \"@angular/core\";\nimport { StorageService } from \"./storage.service\";\n\n@Component({\n  selector: \"app-display\",\n  template: `\u003cbutton (click)=\"showData()\"\u003eShow Data\u003c/button\u003e`,\n})\nexport class DisplayComponent {\n  constructor(private storageService: StorageService) {}\n\n  showData() {\n    const userData = this.storageService.get(\"user\");\n    console.log(\"Retrieved Data:\", userData);\n  }\n}\n```\n\n# Using RxJS\n\n### Step 1: Create the Service\n\n```ts\nimport { Injectable } from \"@angular/core\";\nimport { BehaviorSubject } from \"rxjs\";\n\n@Injectable({\n  providedIn: \"root\",\n})\nexport class StorageService {\n  private storage = new BehaviorSubject\u003cRecord\u003cstring, any\u003e\u003e({});\n\n  // Save data by key\n  save(key: string, value: any): void {\n    const currentData = this.storage.value;\n    this.storage.next({ ...currentData, [key]: value });\n  }\n\n  // Retrieve data by key\n  get(key: string): any {\n    return this.storage.value[key];\n  }\n\n  // Subscribe to data changes (optional)\n  watch(key: string) {\n    return this.storage.asObservable();\n  }\n\n  // Delete data by key\n  remove(key: string): void {\n    const currentData = this.storage.value;\n    const { [key]: _, ...updatedData } = currentData; // Exclude the key to remove\n    this.storage.next(updatedData);\n  }\n}\n```\n\n## Step 2: Use the Service in Components\n\n### Saving Data\n\n```ts\nimport { Component } from \"@angular/core\";\nimport { StorageService } from \"./storage.service\";\n\n@Component({\n  selector: \"app-root\",\n  template: `\u003cbutton (click)=\"saveData()\"\u003eSave Data\u003c/button\u003e`,\n})\nexport class AppComponent {\n  constructor(private storageService: StorageService) {}\n\n  saveData() {\n    this.storageService.save(\"settings\", { theme: \"dark\", language: \"en\" });\n    console.log(\"Data saved!\");\n  }\n}\n```\n\n### Retrieving Data\n\n```ts\nimport { Component } from \"@angular/core\";\nimport { StorageService } from \"./storage.service\";\n\n@Component({\n  selector: \"app-settings\",\n  template: `\u003cbutton (click)=\"showData()\"\u003eShow Settings\u003c/button\u003e`,\n})\nexport class SettingsComponent {\n  constructor(private storageService: StorageService) {}\n\n  showData() {\n    const settings = this.storageService.get(\"settings\");\n    console.log(\"Retrieved Settings:\", settings);\n  }\n}\n```\n\n### Watching Data Changes\n\n```ts\nimport { Component, OnInit } from \"@angular/core\";\nimport { StorageService } from \"./storage.service\";\n\n@Component({\n  selector: \"app-watch\",\n  template: `\u003cp\u003eCheck console for updates\u003c/p\u003e`,\n})\nexport class WatchComponent implements OnInit {\n  constructor(private storageService: StorageService) {}\n\n  ngOnInit() {\n    this.storageService.watch(\"settings\").subscribe((data) =\u003e {\n      console.log(\"Storage updated:\", data);\n    });\n  }\n}\n```\n\n\n\n\n\n## Comparison: Signals vs. RxJS\n\n| Feature                 | Angular Signals                                | RxJS                                             |\n|-------------------------|-----------------------------------------------|-------------------------------------------------|\n| **Reactivity**          | Simplifies state management for local data.   | Better for managing streams and asynchronous data. |\n| **Simplicity**          | Easier to use for small, reactive storage.    | Requires more setup but offers more flexibility. |\n| **Performance**         | Built for Angular and optimized for change detection. | Slightly heavier due to Observable subscriptions. |\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftauhidul0821%2Fangular-simple-store-by-signal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftauhidul0821%2Fangular-simple-store-by-signal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftauhidul0821%2Fangular-simple-store-by-signal/lists"}