{"id":16234129,"url":"https://github.com/zackify/restor","last_synced_at":"2025-04-08T07:41:53.822Z","repository":{"id":57355124,"uuid":"69070872","full_name":"zackify/restor","owner":"zackify","description":"simpler-than-redux react state management","archived":false,"fork":false,"pushed_at":"2016-10-12T19:42:47.000Z","size":71,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-14T13:15:23.307Z","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/zackify.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":"2016-09-24T00:58:26.000Z","updated_at":"2019-07-15T17:38:40.000Z","dependencies_parsed_at":"2022-08-28T13:20:31.881Z","dependency_job_id":null,"html_url":"https://github.com/zackify/restor","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zackify%2Frestor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zackify%2Frestor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zackify%2Frestor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zackify%2Frestor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zackify","download_url":"https://codeload.github.com/zackify/restor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247800980,"owners_count":20998331,"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-10-10T13:15:06.375Z","updated_at":"2025-04-08T07:41:53.804Z","avatar_url":"https://github.com/zackify.png","language":"JavaScript","readme":"[![CircleCI](https://circleci.com/gh/zackify/restor.svg?style=svg\u0026circle-token=ac016b20203ae7e83ea04ccaf0df3248fc62f118)](https://circleci.com/gh/zackify/restor)\n[![Coverage Status](https://coveralls.io/repos/github/zackify/restor/badge.svg?branch=master)](https://coveralls.io/github/zackify/restor?branch=master)\n\n# restor\nsimpler-than-redux react state management\n\n**Early stages, lots of stuff not done :P **\n\n##Install\n\n```\nnpm install restor --save\n```\n\n\n##Example\n\nSee `/example`. Clone, npm install, npm start to see.\n\n##Quickstart\n\nAnywhere you need to update state from a different place, you import the store, and dispatch an update. The example covers this very well.\n\n\n```js\n//todos.js\n\nimport React from 'react';\nimport { connection } from 'restor'\n\nconst Todos = ({ todos }) =\u003e (\n  \u003cdiv\u003e\n    {todos.map(post =\u003e \u003cdiv key={post}\u003e{post}\u003c/div\u003e)}\n  \u003c/div\u003e\n)\nexport default connection('todos')(Todos)\n\n\n//or\n\nimport React from 'react';\nimport { Inject } from 'restor'\n\nexport default () =\u003e (\n  \u003cdiv\u003e\n    \u003cInject state=\"todos\"\u003e\n      {todos =\u003e todos.map(post =\u003e \u003cdiv key={post}\u003e{post}\u003c/div\u003e)}\n    \u003c/Inject\u003e\n  \u003c/div\u003e\n)\n\n\n```\n\nNow, in a completely separate place in the react state tree, we can call `store.dispatch`\n\n```js\n//random-component.js\n\nimport { dispatch } from 'restor'\n\n...\ncomponentDidMount() {\n  dispatch('todos', () =\u003e ['new todos from footer!'])\n  //or update the current state\n  dispatch('todos', (state) =\u003e state.concat(['new todos from footer!']))\n}\n...\n\n```\n\n\n## Middleware\n\nMiddleware is simple to use.\n```js\n\nimport { use } from 'restor'\n\nconst logger = store =\u003e next =\u003e action =\u003e {\n  console.log('Action Received:', action.key, action.value)\n  console.log('New State:', store.state())\n}\n\nconst todoInjector = store =\u003e next =\u003e ({ key, value }) =\u003e {\n  if(key !== 'todos') return\n  let items = [...value]\n  items[1] = 'middleware injected'\n  next(items)\n}\n\nuse(logger)\nuse(todoInjector)\n\n//or\nuse([logger, todoInjector])\n\n```\n##API\n\n`import { state, dispatch, Inject, connection } from 'restor'``\n\n`state`: function returning current store state `state()`\n\n`dispatch`: Update the state in the store\n\nThis gives you the current state at the specfied key, and you must return a new version of that state.\n\n- `dispatch('todos', state =\u003e newState)`\n\n`Inject` Component Props:\n- state `state={state key}`\n\n`connection` HOC:\n- `connection(state key)(Component)`\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzackify%2Frestor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzackify%2Frestor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzackify%2Frestor/lists"}