{"id":14962689,"url":"https://github.com/chainlist/svelte-syncable","last_synced_at":"2025-08-01T07:46:46.223Z","repository":{"id":44126284,"uuid":"193703543","full_name":"chainlist/svelte-syncable","owner":"chainlist","description":"Syncable store for Svelte","archived":false,"fork":false,"pushed_at":"2023-01-04T01:04:43.000Z","size":1645,"stargazers_count":26,"open_issues_count":19,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-09-29T12:02:12.937Z","etag":null,"topics":["svelte","svelte-framework","svelte-js","svelte-v3","svelte3","sveltejs"],"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/chainlist.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}},"created_at":"2019-06-25T12:28:53.000Z","updated_at":"2022-07-01T21:04:46.000Z","dependencies_parsed_at":"2023-02-01T17:02:24.267Z","dependency_job_id":null,"html_url":"https://github.com/chainlist/svelte-syncable","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chainlist%2Fsvelte-syncable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chainlist%2Fsvelte-syncable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chainlist%2Fsvelte-syncable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chainlist%2Fsvelte-syncable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chainlist","download_url":"https://codeload.github.com/chainlist/svelte-syncable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219867387,"owners_count":16555891,"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":["svelte","svelte-framework","svelte-js","svelte-v3","svelte3","sveltejs"],"created_at":"2024-09-24T13:30:22.620Z","updated_at":"2024-10-10T12:43:02.778Z","avatar_url":"https://github.com/chainlist.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Svelte Store Storage plugin [![Build Status](https://travis-ci.org/chainlist/svelte-syncable.svg?branch=master)](https://travis-ci.org/chainlist/svelte-syncable)\n\n## Install\n\n`npm i -D svelte-syncable`\n\nor\n\n`yarn add -D svelte-syncable`\n\n## How to use\n\n\nSetting a prefix is optional, the default one is `svelteStore`\n\nCreate your syncable store value\n```javascript\n// store.js\nimport { syncable, setPrefix } from 'svelte-syncable';\n\n// All the syncable value will be stored as \"foorbar-{name}\"\nsetPrefix('foobar');\n\nexport const answer = syncable('answer', 42);\nexport const todos = syncable('todos', [\n    { id: 1, text: 'Find the answer of life', done: false }\n]);\n```\n\nUse your store value as every other svelte store observables\n```html\n// Component.svelte\n\u003cscript\u003e\n    import { answer, todos } from './store.js';\n\u003c/script\u003e\n\n\u003cul\u003e\n    {#each $todos as todo, todo.id}\n        \u003cli\u003e{todo.text}\u003c/li\u003e\n    {/each}\n\u003c/ul\u003e\n\nThe count is {$answer}\n```\n\n## API\n\n### setPrefix(prefix: string): void\n\nSet the localStorage prefix to {name}\nThe function has to be called on the top of your store.js file.\n\n### syncable(name: string, value: any, hydrate: boolean = true): SvelteObservable\n\nCreate a svelte observable store value and synchronize it with the localStorage.\nThe value will by hydrated from the localStorage by default, set `hydrate` to false to avoid this behavior.\nThe `hydrate` parameter is optional and set to true by default.\n\n\n```javascript\nimport { syncable } from 'svelte-syncable';\nimport { writable } from 'svelte/store';\n\nexport const count = syncable('count', 0, false);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchainlist%2Fsvelte-syncable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchainlist%2Fsvelte-syncable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchainlist%2Fsvelte-syncable/lists"}