{"id":42830735,"url":"https://github.com/weavedev/store","last_synced_at":"2026-01-30T11:27:42.673Z","repository":{"id":40887673,"uuid":"234103943","full_name":"weavedev/store","owner":"weavedev","description":"Opinionated drop-in redux store with redux-saga","archived":false,"fork":false,"pushed_at":"2022-09-19T13:32:16.000Z","size":752,"stargazers_count":2,"open_issues_count":4,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-28T10:08:01.549Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/weavedev.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2020-01-15T14:56:32.000Z","updated_at":"2021-10-29T14:05:33.000Z","dependencies_parsed_at":"2023-01-18T09:47:47.588Z","dependency_job_id":null,"html_url":"https://github.com/weavedev/store","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/weavedev/store","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weavedev%2Fstore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weavedev%2Fstore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weavedev%2Fstore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weavedev%2Fstore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weavedev","download_url":"https://codeload.github.com/weavedev/store/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weavedev%2Fstore/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28911821,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-30T08:15:08.179Z","status":"ssl_error","status_checked_at":"2026-01-30T08:14:31.507Z","response_time":66,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2026-01-30T11:27:42.020Z","updated_at":"2026-01-30T11:27:42.668Z","avatar_url":"https://github.com/weavedev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# store\n\n[![Build Status - Travis CI](https://img.shields.io/travis/weavedev/store.svg)](https://travis-ci.org/weavedev/store)\n[![Test Coverage - Code Climate](https://img.shields.io/codeclimate/coverage/weavedev/store.svg)](https://codeclimate.com/github/weavedev/store/test_coverage)\n[![MIT](https://img.shields.io/github/license/weavedev/store.svg)](https://github.com/weavedev/store/blob/master/LICENSE)\n[![NPM](https://img.shields.io/npm/v/@weavedev/store.svg)](https://www.npmjs.com/package/@weavedev/store)\n\nOpinionated drop-in [Redux](http://redux.js.org/) store with [Redux-Saga](https://redux-saga.js.org)\n\n## Install\n\n```\nnpm i @weavedev/store\n```\n\n## API documentation\n\nWe generate API documentation with [TypeDoc](https://typedoc.org).\n\n[![API Documentation](https://img.shields.io/badge/API-Documentation-blue?style=for-the-badge\u0026logo=typescript)](https://weavedev.github.io/store/)\n\n## Usage\n\n### Initialization\n\n#### Basic initialization\n\nThe recommended way to create the `store` is with the `init()` function.\n\n```ts\nimport { init } from '@weavedev/store/init';\n\ninit();\n```\n\n#### Custom initialization with middlewares\n\nIf you want to use your own middlewares you can pass them as arguments.\n\n```ts\nimport { init } from '@weavedev/store/init';\nimport { logger, router, uploader } from './middlewares';\n\ninit(logger, router, uploader);\n```\n\n#### Automatic initialization\n\nWhen the `store` object is imported and `window.store` has not already been initialized this package will initialize it for you.\n\n```ts\nimport { store } from '@weavedev/store';\n```\n\n###### NOTE\n\nThe purpose of automatic initialization and the importable `store` object are to provide an easy way to migrate an existing project. Manually initializing the store is recommended.\n\n### Reducers\n\n#### Adding reducers\n\nAdding reducers to the `window.storeReducers` object registers them on the `store` and allows you to dispatch actions on them.\n\n```ts\nimport { Action, Reducer } from 'redux';\n\n// Clear message action\nexport const CLEAR_MESSAGE = 'CLEAR_MESSAGE';\ntype ClearMessage = Action\u003ctypeof CLEAR_MESSAGE\u003e;\nexport const clearMessage = (): ClearMessage =\u003e ({\n    type: CLEAR_MESSAGE,\n});\n\n// Set message action\nexport const SET_MESSAGE = 'SET_MESSAGE';\ninterface SetMessage extends Action\u003ctypeof SET_MESSAGE\u003e {\n    message: string;\n}\nexport const setMessage = (message: string): SetMessage =\u003e ({\n    type: SET_MESSAGE,\n    message,\n});\n\n// Message reducer\nwindow.storeReducers.myMessageReducer = (state: string = 'default value', action: StoreActions): string =\u003e {\n    switch(action.type) {\n        case 'CLEAR_MESSAGE':\n            return '';\n        case 'SET_MESSAGE':\n            return action.message;\n        default:\n            return state;\n    }\n};\n\ndeclare global {\n    interface StoreReducersMap {\n        myMessageReducer: Reducer\u003cstring, StoreActions\u003e;\n    }\n\n    interface StoreActionsMap {\n        myMessageReducer: SetMessage | ClearMessage;\n    }\n}\n```\n\n#### Removing reducers\n\nAfter removing a reducer from `window.storeReducers` it will no longer listen to dispatched actions. After a reducer is removed from `window.storeReducers` its state will be removed.\n\n```ts\ndelete window.storeReducers.myMessageReducer;\n```\n\n### Sagas\n\n#### Adding sagas\n\nAdding sagas to the `window.storeSagas` object registers them on the `store` and runs them to start listening to dispatched actions.\n\n```ts\nimport { call, takeLatest } from 'redux-saga/effects';\nimport { SetMessage } from './myMessageReducer';\n\n// Message saga\nwindow.storeSagas.myMessageSaga = function* (): Iterator\u003cany\u003e {\n    yield takeLatest('SET_MESSAGE', function* (action: SetMessage): Iterator\u003cany\u003e {\n        yield call(console.log, action.message);\n    });\n};\n```\n\n#### Removing sagas\n\nAfter removing a saga from `window.storeSagas` it will no longer listen to dispatched actions and if the saga is running it will be cancelled.\n\n```ts\ndelete window.storeSagas.myMessageSaga;\n```\n\n### Global types\n\nThis package provides the following global types\n\n#### `StoreActions`\n\nAny actions known to the store. Useful when creating reducers.\n\n```ts\nfunction myReducer(state: string, action: StoreActions): string {\n    // ...\n}\n```\n\n#### `StoreActionsMap`\n\nAny actions you want to use with the store you can add to the `StoreActionsMap`. These actions will be available on the global `StoreActions` type.\n\n```ts\ndeclare global {\n    interface StoreActionsMap {\n        myReducer: Action\u003c'MY_ACTION'\u003e;\n    }\n}\n```\n\n#### `StoreReducersMap`\n\nAny reducers you want to use with the store you can add to the `StoreReducersMap`. This wil also bind the types to `StoreState`.\n\n```ts\ndeclare global {\n    interface StoreReducersMap {\n        myReducer: Reducer\u003cstring, StoreActions\u003e;\n    }\n}\n```\n\n#### `StoreSagasMap`\n\nIt exists. You will probably not need it. But just in case you are looking for it, here it is.\n\n```ts\ndeclare global {\n    interface StoreSagasMap {\n        mySaga: Saga;\n    }\n}\n```\n\n#### `StoreState`\n\nThe `StoreState` type describes the return type of `window.store.getState()`. Useful when using stored values.\n\n```ts\nconst state: StoreState = window.store.getState();\n```\n\n### Logging\n\nSetting `window.DEV_MODE` to `true` before initializing will enable logging in the console and with the [Chrome Redux DevTools](https://chrome.google.com/webstore/detail/redux-devtools/lmhkpmbekcpmknklioeibfkpmmfibljd?hl=en).\n\n```ts\nimport { init } from '@weavedev/store/init';\n\nwindow.DEV_MODE = true;\n\ninit();\n```\n\n## License\n\n[MIT](https://github.com/weavedev/store/blob/master/LICENSE)\n\nMade by [Paul Gerarts](https://github.com/gerarts) and [Weave](https://weave.nl)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweavedev%2Fstore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweavedev%2Fstore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweavedev%2Fstore/lists"}