{"id":15506237,"url":"https://github.com/fi3ework/redux-analysis","last_synced_at":"2025-10-07T21:52:07.677Z","repository":{"id":66226782,"uuid":"119400168","full_name":"fi3ework/redux-analysis","owner":"fi3ework","description":" :microscope: redux 源码分析","archived":false,"fork":false,"pushed_at":"2018-04-23T08:27:14.000Z","size":20,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-23T01:56:10.579Z","etag":null,"topics":["redux"],"latest_commit_sha":null,"homepage":"","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/fi3ework.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-29T15:21:32.000Z","updated_at":"2019-10-15T09:04:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"d020f2c4-b159-49bc-afe8-382bd764f03a","html_url":"https://github.com/fi3ework/redux-analysis","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/fi3ework%2Fredux-analysis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fi3ework%2Fredux-analysis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fi3ework%2Fredux-analysis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fi3ework%2Fredux-analysis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fi3ework","download_url":"https://codeload.github.com/fi3ework/redux-analysis/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250354304,"owners_count":21416751,"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"],"created_at":"2024-10-02T09:26:24.969Z","updated_at":"2025-10-07T21:52:07.586Z","avatar_url":"https://github.com/fi3ework.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## 说明\n\n**本文所分析的Redux版本为3.7.2**\n\n分析代码时通过查看Github Blame，参考了Redux的issue及PR来分析各个函数的意图而不仅是从代码层面分析函数的作用，并且分析了很多细节层面上写法的原因，比如：\n\n1. `dispatch: (...args) =\u003e dispatch(…args)` 为什么不只传递一个 `action` ?\n\n2. `listener` 的调用为什么从 `forEach` 改成了 `for` ?\n\n3. 为什么在 `reducer` 的调用过程中不允许 `dispatch(action)` ?\n\n   ...\n\n水平有限，有写的不好或不对的地方请指出，欢迎留[issue](https://github.com/fi3ework/redux-analysis/issues)交流😆\n\n## 文件结构\n\nRedux的文件结构并不复杂，每个文件就是一个对外导出的函数，依赖很少，分析起来也比较容易，只要会用Redux基本上都能看懂本文。\n这是Redux的目录结构：\n```\n.\n├── applyMiddleware.js       将middleware串联起来生成一个更强大的dispatch函数，就是中间件的本质作用\n├── bindActionCreators.js    把action creators转成拥有同名keys的对象\n├── combineReducers.js       将多个reducer组合起来，每一个reducer独立管理自己对应的state\n├── compose.js               将middleware从右向左依次调用，函数式编程中的常用方法，被applyMiddleware调用\n├── createStore.js           最核心功能，创建一个store，包括实现了subscribe, unsubscribe, dispatch及state的储存\n├── index.js                 对外export\n└── utils                    一些小的辅助函数供其他的函数调用\n   ├── actionTypes.js        redux内置的action，用来初始化initialState\n   ├── isPlainObject.js      用来判断是否为单纯对象\n   └── warning.js            报错提示\n\n```\n## 源码分析\n\n直接写在代码的注释里了，在每个函数上方也有大段的官方注释来解释每个函数的作用，中文翻译可以见[Redux 中文文档](http://github.com/camsong/redux-in-chinese)\n\n**推荐源码的阅读顺序为：**\n\n```\nindex.js -\u003e creatStore.js -\u003e applyMiddleware.js (compose.js) -\u003e combineReducers.js -\u003e bindActionCreators.js\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffi3ework%2Fredux-analysis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffi3ework%2Fredux-analysis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffi3ework%2Fredux-analysis/lists"}