{"id":23132062,"url":"https://github.com/natserract/local-storage-observer","last_synced_at":"2025-08-17T08:32:05.979Z","repository":{"id":120760824,"uuid":"427802995","full_name":"natserract/local-storage-observer","owner":"natserract","description":"💾 Offline storage using local storage running in Observer","archived":false,"fork":false,"pushed_at":"2021-11-18T02:40:37.000Z","size":371,"stargazers_count":4,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-09T10:10:04.670Z","etag":null,"topics":["library","localstorage","observable"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/local-storage-observer","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/natserract.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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,"zenodo":null}},"created_at":"2021-11-14T00:27:18.000Z","updated_at":"2021-12-17T02:24:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"b6e10ded-27b4-4fb4-add9-2d9d960dc97a","html_url":"https://github.com/natserract/local-storage-observer","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/natserract/local-storage-observer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natserract%2Flocal-storage-observer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natserract%2Flocal-storage-observer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natserract%2Flocal-storage-observer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natserract%2Flocal-storage-observer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/natserract","download_url":"https://codeload.github.com/natserract/local-storage-observer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natserract%2Flocal-storage-observer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270823103,"owners_count":24652045,"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-08-17T02:00:09.016Z","response_time":129,"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":["library","localstorage","observable"],"created_at":"2024-12-17T11:16:54.146Z","updated_at":"2025-08-17T08:32:05.967Z","avatar_url":"https://github.com/natserract.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LocalStorage Observer\n\nCalled **localStorageObserver** this is a simple storage library for JavaScript, get inspire from **localForage** but running as **Observer**. This library support TypeScript, and EasyTo-Use.\n\nProblems why created this library:\n\n```js\nwindow.addEventListener('storage', () =\u003e {})\n```\n\n\u003e This won't work on the same page that is making the changes — it is really a way for other pages on the domain using the storage to sync any changes that are made. Pages on other domains can't access the same storage objects. [https://developer.mozilla.org/en-US/docs/Web/API/Window/storage_event](https://developer.mozilla.org/en-US/docs/Web/API/Window/storage_event)\n\n## How to use\n\nTo use localStorageObserver, just drop a single line into your app:\n\n```ts\nimport localStorageObserver from 'local-storage-observer'\n```\n\nSee more [real example](https://github.com/natserract/local-storage-observer/tree/master/examples).\n\nDownload the [latest localStorageObserver from GitHub](https://github.com/natserract/local-storage-observer), or install with npm:\n\n```terminal\nnpm install local-storage-observer\n```\n\n## Configuration\n\nYou can set several configuration with the `config()` method. Avalaible options `description`, `storeName`, and `version` (use for future, currently isn't some affect in your app).\n\nExample:\n\n```ts\nlocalStorageObserver.config({\n  storeName: 'local_storage_observer',\n})\n```\n\nNote: you must call `config()` before you interact with your data. This means calling `config()` before using `get$()`, or `set$()`.\n\n## Get Item\n\nGets an item from the local storage and supplies the result to a subscriber. If the key does not exist, get\\$() will return `null`.\n\n```ts\nlocalStorageObserver.get$(key).subscribe((next) =\u003e {\n  console.log('Result', JSON.parse(next))\n})\n```\n\n\u003e Note: localStorageObserver doesn't store the value null / undefined.\n\n## Set Item\n\nSaves data to local storage.\n\n```ts\nlocalStorageObserver.set$(key, values).subscribe((next) =\u003e {\n  console.log('Step two, set$', next)\n})\n```\n\nYou can store the following types of JavaScript objects:\n\n- `Array`\n- `String`\n- `Number`\n- `Object`\n\n## Remove Item\n\nRemoves the value of a key from the local storage.\n\n```ts\nlocalStorageObserver.remove$(key).subscribe({\n  next: (message) =\u003e console.log('Message: ', message),\n  error: (error) =\u003e console.error('Error: ', error),\n})\n```\n\n## Clear Item\n\nRemoves the value of a key from the local storage.\n\n```ts\nlocalStorageObserver.clear$().subscribe((message) =\u003e {\n  console.log('Message: ', message)\n})\n```\n\n## Unsubscribe\n\nCleanup a subscription\n\n```tsx\nuseEffect(() =\u003e {\n  ...\n\n  return () =\u003e {\n    localStorageObserver.destroySubscription()\n  }\n}, [])\n```\n\n## License\n\nThis program is free software; it is distributed under an [MIT License](https://github.com/natserract/local-storage-observer/blob/master/LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnatserract%2Flocal-storage-observer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnatserract%2Flocal-storage-observer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnatserract%2Flocal-storage-observer/lists"}