{"id":18711914,"url":"https://github.com/algolia/redux-magic-async-middleware","last_synced_at":"2025-08-19T06:35:00.884Z","repository":{"id":57350972,"uuid":"63061225","full_name":"algolia/redux-magic-async-middleware","owner":"algolia","description":"redux-magic-async-middleware is a middleware which makes it easy to handle asynchronous data with redux","archived":false,"fork":false,"pushed_at":"2018-05-28T19:41:20.000Z","size":10,"stargazers_count":23,"open_issues_count":0,"forks_count":5,"subscribers_count":70,"default_branch":"master","last_synced_at":"2025-06-19T15:52:23.366Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/algolia.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":"2016-07-11T11:10:31.000Z","updated_at":"2021-01-10T04:10:48.000Z","dependencies_parsed_at":"2022-09-17T22:20:51.102Z","dependency_job_id":null,"html_url":"https://github.com/algolia/redux-magic-async-middleware","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/algolia/redux-magic-async-middleware","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/algolia%2Fredux-magic-async-middleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/algolia%2Fredux-magic-async-middleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/algolia%2Fredux-magic-async-middleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/algolia%2Fredux-magic-async-middleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/algolia","download_url":"https://codeload.github.com/algolia/redux-magic-async-middleware/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/algolia%2Fredux-magic-async-middleware/sbom","scorecard":{"id":183261,"data":{"date":"2025-08-11","repo":{"name":"github.com/algolia/redux-magic-async-middleware","commit":"dd7e0f9225de722405f14ed29d03f362aebff4c7"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.8,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/4 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: npmCommand not pinned by hash: scripts/release.sh:29","Info:   0 out of   1 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}}]},"last_synced_at":"2025-08-16T19:16:52.744Z","repository_id":57350972,"created_at":"2025-08-16T19:16:52.744Z","updated_at":"2025-08-16T19:16:52.744Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271113506,"owners_count":24701609,"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","status":"online","status_checked_at":"2025-08-19T02:00:09.176Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":"2024-11-07T12:40:43.664Z","updated_at":"2025-08-19T06:35:00.834Z","avatar_url":"https://github.com/algolia.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# redux-magic-async-middleware\n\n`redux-magic-async-middleware` is a middleware which makes it easy to handle asynchronous data with redux. Combine it with [redux-updeep] for increased awesomeness and reduced boilerplate !\n\n[![Version][version-svg]][package-url] [![Build Status][travis-svg]][travis-url] [![License][license-image]][license-url]\n\n\n## Installation\n\n`redux-magic-async-middleware` is available on npm. You'll need [redux-updeep] to take full advantage of it.\n\n```bash\nnpm install -S redux-magic-async-middleware redux-updeep\n```\n\n## Getting started\n\n### 1. Add as a middleware\n\nJust add it as you would add any middleware\n\n```js\nimport {createStore, applyMiddleware, combineReducers} from 'redux';\nimport magicAsyncMiddleware from 'redux-magic-async-middleware';\n\nlet combinedReducers = combineReducers(...);\nlet otherMiddlewares = [...];\n\nlet store = createStore(\n  combinedReducers,\n  applyMiddleware(\n    magicAsyncMiddleware,\n    ...otherMiddlewares\n  )\n);\n```\n\n### 2. Dispatch promises in your action payload as if they were synchronous values\n\nRemember how [redux-updeep] lets you easily dispatch actions and merges the payload automatically in your state ? Well, using `redux-magic-async-middleware` you can do the same with promises. While they are loading, they are represented by [eventual values](https://github.com/algolia/eventual-values), so you can check their status easily. Once they are resolved the data will automatically be updated.\n\n```js\nconst initialState = {\n  user: undefined,\n  projectList: undefined\n};\n\nexport default createReducer('USER', initialState);\n\nexport function loadUserData() {\n  return {\n    type: 'USER/LOAD_USER_DATA',\n    payload: {\n      user: fetch('/user_data'),\n      projectList: fetch('/projectList').then(data =\u003e data.projects)\n    }\n  };\n}\n```\n\n_Note that the middleware will only look for promises in the first level of the payload. If you need more, use a [path](#using-a-path-to-merge-asynchrounous-data-deeply-in-your-reducer-state)_\n\n### 3. Use the data in your components\n\n```js\nimport React from 'react';\nimport {connect} from 'react-redux'\nimport {isReady} from 'eventual-values';\n\nfunction MyComponent({user}) {\n  if (isReady(user)) {\n    return \u003ch1\u003eHello {user.name}\u003c/h1\u003e;\n  }\n\n  return \u003cspan\u003eLoading\u003c/span\u003e;\n}\n\nexport default connect(({myReducer: {user}}) =\u003e ({user}))(MyComponent);\n```\n\n## Advanced usage\n\n### Using a path to merge asynchronous data deeply in your reducer state\n\nAs mentioned the middleware will only look for promises at the first level in the payload. If the asynchronous data needs to be updated deeper into the reducer state, use a [path](https://github.com/algolia/redux-updeep#specifying-a-path).\n\n```js\nconst initialState = {\n  user: undefined,\n  projectList: undefined\n};\n\nexport default createReducer('USER', initialState);\n\nexport function loadName() {\n  return {\n    type: 'USER/LOAD_NAME',\n    payload: {\n      name: fetch('/user_name')\n    },\n    path: ['user']\n  };\n}\n```\n\n### Refreshing data \u0026 loading state\n\nBy default, the middleware will only mark values as loading if they were `undefined` when the actions were dispatched.\n\nThis means that if a key on the reducer's state has a value, and if then a promised is dispatched at this key, then nothing will happen to the reducer state until the promise is resolved or rejected.\n\nIt is possible to override this behaviour and reset the value to a loading eventual value at every dispatch by using the overrideStatus key in the action:\n\n```js\nconst initialState = {\n  user: undefined,\n  projectList: undefined\n};\n\nexport default createReducer('USER', initialState);\n\nexport function loadUserData() {\n  return {\n    type: 'USER/LOAD_USER_DATA',\n    overrideStatus: true,\n    payload: {\n      user: fetch('/user_data')\n    }\n  };\n}\n```\n\n\n[version-svg]: https://img.shields.io/npm/v/redux-magic-async-middleware.svg?style=flat-square\n[package-url]: https://npmjs.org/package/redux-magic-async-middleware\n[travis-svg]: https://img.shields.io/travis/algolia/redux-magic-async-middleware/master.svg?style=flat-square\n[travis-url]: https://travis-ci.org/algolia/redux-magic-async-middleware\n[license-image]: http://img.shields.io/badge/license-MIT-green.svg?style=flat-square\n[license-url]: LICENSE\n[downloads-image]: https://img.shields.io/npm/dm/redux-matic-async-middleware.svg?style=flat-square\n[downloads-url]: http://npm-stat.com/charts.html?package=redux-magic-async-middleware\n[redux-updeep]: https://github.com/algolia/redux-updeep","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falgolia%2Fredux-magic-async-middleware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falgolia%2Fredux-magic-async-middleware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falgolia%2Fredux-magic-async-middleware/lists"}