{"id":14962686,"url":"https://github.com/dai-shi/svelte3-redux","last_synced_at":"2025-10-25T00:30:40.146Z","repository":{"id":35114741,"uuid":"208524346","full_name":"dai-shi/svelte3-redux","owner":"dai-shi","description":"[NOT MAINTAINED] Redux for Svelte 3","archived":false,"fork":false,"pushed_at":"2023-01-07T14:51:50.000Z","size":3861,"stargazers_count":30,"open_issues_count":23,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-09-29T12:02:18.650Z","etag":null,"topics":["redux","svelte","svelte3"],"latest_commit_sha":null,"homepage":"","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/dai-shi.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-15T01:10:07.000Z","updated_at":"2023-07-03T15:56:05.000Z","dependencies_parsed_at":"2023-01-15T14:15:20.634Z","dependency_job_id":null,"html_url":"https://github.com/dai-shi/svelte3-redux","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dai-shi%2Fsvelte3-redux","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dai-shi%2Fsvelte3-redux/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dai-shi%2Fsvelte3-redux/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dai-shi%2Fsvelte3-redux/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dai-shi","download_url":"https://codeload.github.com/dai-shi/svelte3-redux/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":["redux","svelte","svelte3"],"created_at":"2024-09-24T13:30:22.358Z","updated_at":"2025-10-25T00:30:39.727Z","avatar_url":"https://github.com/dai-shi.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# svelte3-redux\n\n[![CI](https://img.shields.io/github/workflow/status/dai-shi/svelte3-redux/CI)](https://github.com/dai-shi/svelte3-redux/actions?query=workflow%3ACI)\n[![npm](https://img.shields.io/npm/v/svelte3-redux)](https://www.npmjs.com/package/svelte3-redux)\n[![size](https://img.shields.io/bundlephobia/minzip/svelte3-redux)](https://bundlephobia.com/result?p=svelte3-redux)\n\nRedux for Svelte 3\n\n## Introduction\n\nThis is an experimental project to combine Redux and Svelte3.\nIt provides the same state usage tracking support\nin [reactive-react-redux](https://github.com/dai-shi/reactive-react-redux).\n\n## Install\n\n```bash\nnpm install svelte3-redux\n```\n\n## Usage (bind)\n\nThis is simple usage.\nReactivity works for all components.\n\n```html\n\u003cscript\u003e\nimport { createStore } from 'redux';\nimport { bind } from 'svelte3-redux';\n\nconst initialState = {\n  count: 0,\n  text: 'hello',\n};\n\nconst reducer = (state = initialState, action) =\u003e {\n  switch (action.type) {\n    case 'increment': return { ...state, count: state.count + 1 };\n    case 'decrement': return { ...state, count: state.count - 1 };\n    case 'setText': return { ...state, text: action.text };\n    default: return state;\n  }\n};\n\nconst store = createStore(reducer);\nconst state = bind(store);\n\u003c/script\u003e\n\n\u003ch1\u003eCounter\u003c/h1\u003e\n\u003cdiv\u003e\n  \u003cdiv\u003e\n    \u003cspan\u003eCount: {$state.count}\u003c/span\u003e\n    \u003cbutton on:click={() =\u003e state.dispatch({ type: 'increment' })}\u003e+1\u003c/button\u003e\n    \u003cbutton on:click={() =\u003e state.dispatch({ type: 'decrement' })}\u003e-1\u003c/button\u003e\n  \u003c/div\u003e\n\u003c/div\u003e\n \n\u003ch1\u003eTextBox\u003c/h1\u003e\n\u003cdiv\u003e\n  \u003cdiv\u003e\n    \u003cspan\u003eText: {$state.text}\u003c/span\u003e\n    \u003cinput value={$state.text} on:input={event =\u003e state.dispatch({ type: 'setText', text: event.target.value })} /\u003e\n  \u003c/div\u003e\n\u003c/div\u003e\n```\n\n## Usage (bindTracked)\n\nThis is recommended usage.\nReactivity works based on state usage tracking.\n\n### store.js\n\n```javascript\nimport { createStore } from 'redux';\nimport { bindTracked } from 'svelte3-redux';\n\nconst initialState = {\n  count: 0,\n  text: 'hello',\n};\n\nconst reducer = (state = initialState, action) =\u003e {\n  switch (action.type) {\n    case 'increment': return { ...state, count: state.count + 1 };\n    case 'decrement': return { ...state, count: state.count - 1 };\n    case 'setText': return { ...state, text: action.text };\n    default: return state;\n  }\n};\n\nconst store = createStore(reducer);\nexport default () =\u003e bindTracked(store);\n```\n\n### Counter.svelte\n\n```html\n\u003cscript\u003e\n  import getTrackedState from './store';\n\n  const state = getTrackedState();\n\u003c/script\u003e\n\n\u003ch1\u003eCounter\u003c/h1\u003e\n\u003cdiv\u003e\n  \u003cdiv\u003e\n    \u003cspan\u003eCount: {$state.count}\u003c/span\u003e\n    \u003cbutton on:click={() =\u003e state.dispatch({ type: 'increment' })}\u003e+1\u003c/button\u003e\n    \u003cbutton on:click={() =\u003e state.dispatch({ type: 'decrement' })}\u003e-1\u003c/button\u003e\n  \u003c/div\u003e\n\u003c/div\u003e\n```\n\n### TextBox.svelte\n\n```html\n\u003cscript\u003e\n  import getTrackedState from './store';\n\n  const state = getTrackedState();\n\u003c/script\u003e\n\n\u003ch1\u003eTextBox\u003c/h1\u003e\n\u003cdiv\u003e\n  \u003cdiv\u003e\n    \u003cspan\u003eText: {$state.text}\u003c/span\u003e\n    \u003cinput value={$state.text} on:input={event =\u003e state.dispatch({ type: 'setText', text: event.target.value })} /\u003e\n  \u003c/div\u003e\n\u003c/div\u003e\n```\n\n## API\n\n\u003c!-- Generated by documentation.js. Update this documentation by updating the source code. --\u003e\n\n### bind\n\nTake Redux store and return a global state for Svelte.\n\n#### Parameters\n\n-   `store` **Store\u0026lt;State, Action\u003e** \n\n#### Examples\n\n```javascript\nimport { createStore } from 'redux';\nimport { bind } from 'svelte3-redux';\n\nconst store = createStore(reducer);\nexport default bind(store);\n```\n\n### bindTracked\n\nTake Redux store and return a global state for Svelte.\nWith state usage tracking.\n\n#### Parameters\n\n-   `store` **Store\u0026lt;State, Action\u003e** \n\n#### Examples\n\n```javascript\nimport { createStore } from 'redux';\nimport { bindTracked } from 'svelte3-redux';\n\nconst store = createStore(reducer);\nexport default () =\u003e bindTracked(store);\n```\n\n## Examples\n\nThe [examples](examples) folder contains working examples.\nYou can run one of them with\n\n```bash\nPORT=8080 npm run examples:01_minimal\n```\n\nand open \u003chttp://localhost:8080\u003e in your web browser.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdai-shi%2Fsvelte3-redux","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdai-shi%2Fsvelte3-redux","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdai-shi%2Fsvelte3-redux/lists"}