{"id":19522174,"url":"https://github.com/captaincodeman/svelte-state-store","last_synced_at":"2025-04-26T09:32:05.723Z","repository":{"id":205799677,"uuid":"715179847","full_name":"CaptainCodeman/svelte-state-store","owner":"CaptainCodeman","description":null,"archived":false,"fork":false,"pushed_at":"2024-04-27T18:39:04.000Z","size":52,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-04T10:36:31.501Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/CaptainCodeman.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":"2023-11-06T16:20:49.000Z","updated_at":"2024-06-05T23:19:02.000Z","dependencies_parsed_at":"2024-11-11T00:37:33.047Z","dependency_job_id":"b8ccf20b-c230-4100-b8a6-fde43ab33b11","html_url":"https://github.com/CaptainCodeman/svelte-state-store","commit_stats":null,"previous_names":["captaincodeman/svelte-state-store"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaptainCodeman%2Fsvelte-state-store","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaptainCodeman%2Fsvelte-state-store/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaptainCodeman%2Fsvelte-state-store/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaptainCodeman%2Fsvelte-state-store/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CaptainCodeman","download_url":"https://codeload.github.com/CaptainCodeman/svelte-state-store/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250967223,"owners_count":21515563,"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-11T00:37:30.544Z","updated_at":"2025-04-26T09:32:05.496Z","avatar_url":"https://github.com/CaptainCodeman.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# svelte-state-store\n\nA [Svelte writable store](https://svelte.dev/docs/svelte-store#writable) that allows immediate access to the current state via a `value` getter.\nThis avoids the need to use the less efficient `get(store)` and to access the current store value without having to setup a subscription which can sometimes be awkward.\n\nIt can be useful where you need a store value but it isn't a dependency that would need to trigger an update or you would otherwise need to `get` the value inside a tight loop (e.g. a mouseover handler checking for the pointer being over objects that are within a store, to set the highlighted one). In certain situations it can help create simpler more efficient code.\n\n## Usage\n\nInstall using your package-manager of choice, e.g.\n\n    pnpm i -D svelte-state-store\n\nImport and use just as you would a regular `writable` store:\n\n```ts\nimport { state } from 'svelte-state-store';\n\nexport const my_store = state(123);\n```\n\nYou can now use the store as a regular `writable` store, subscribing to it for updates, and using it with `derived` stores, but you can also access the current value outside of a subscription using:\n\n```ts\nconsole.log(my_store.value); // 123\n```\n\nYou can pass a `StartStopNotifier` to the store, just as with a regular Svelte `writable` store.\n\nIf you need to define a type for your store, use `State` where you would have used `Writable`:\n\n```ts\nimport type { Writable } from 'svelte/store`\n\nfunction that_uses_store(store: Writable\u003cStoreValue\u003e) { }\n```\n\nbecomes ...\n\n```ts\nimport type { State } from 'svelte-state-store`\n\nfunction that_uses_store(store: State\u003cStoreValue\u003e) { }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaptaincodeman%2Fsvelte-state-store","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcaptaincodeman%2Fsvelte-state-store","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaptaincodeman%2Fsvelte-state-store/lists"}