{"action":"created","comment":{"url":"https://api.github.com/repos/xitu/gold-miner/pulls/comments/210300177","pull_request_review_id":146484702,"id":210300177,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMDMwMDE3Nw==","diff_hunk":"@@ -2,42 +2,42 @@\n > * 原文作者：[ANDY BELL](https://css-tricks.com/author/andybell/)\n > * 译文出自：[掘金翻译计划](https://github.com/xitu/gold-miner)\n > * 本文永久链接：[https://github.com/xitu/gold-miner/blob/master/TODO1/build-a-state-management-system-with-vanilla-javascript.md](https://github.com/xitu/gold-miner/blob/master/TODO1/build-a-state-management-system-with-vanilla-javascript.md)\n-> * 译者：\n+> * 译者：[Shery](https://github.com/shery)\n > * 校对者：\n \n-# Build a state management system with vanilla JavaScript\n+# 使用原生 JavaScript 构建状态管理系统\n \n-Managing state is not a new thing in software, but it’s still relatively new for building software in JavaScript. Traditionally, we’d keep state within the DOM itself or even assign it to a global object in the window. Now though, we’re spoiled with choices for libraries and frameworks to help us with this. Libraries like Redux, MobX and Vuex make managing cross-component state almost trivial. This is great for an application’s resilience and it works really well with a state-first, reactive framework such as React or Vue.\n+状态管理在软件方面并不新鲜，但在 JavaScript 构建的应用中仍然相对较新。习惯上，我们会直接将状态保持在 DOM 上，甚至将其分配给 window 中的全局对象。但是现在，我们已经有了许多选择，这些库和框架可以帮助我们管理状态。像 Redux，MobX 和 Vuex 这样的库可以轻松管理跨组件状态。它大大提升了应用程序的适应能力，并且它对于状态优先的响应式框架（如 React 或 Vue）非常有用。\n \n-How do these libraries work though? What would it take to write one ourselves? Turns out, it’s pretty straightforward and there’s an opportunity to learn some really common patterns and also learn about some useful modern APIs that are available to us.\n+这些库是如何运作的？我们自己写个状态管理会怎么样？事实证明，它非常简单，并且有机会学习一些非常常见的设计模式，同时了解一些既有用又能用的现代 API。\n \n-Before we get started, it’s recommended that you have an intermediary knowledge of JavaScript. You should know about data types and ideally, you should have a grasp of some more modern ES6+ JavaScript features. If not, [we’ve got your back](https://css-tricks.com/learning-gutenberg-4-modern-javascript-syntax/). It’s also worth noting that I’m not saying that you should replace Redux or MobX with this. We’re working on a little project to skill-up together and, hey, it could definitely power a small application if you were keeping an eye on the size of your JavaScript payload.\n+在我们开始之前，请确保你已掌握中级 JavaScript 的知识。你应该了解数据类型，理想情况下，你应该掌握一些更现代的 ES6+ 语法特性。如果没有，[这可以帮到你](https://css-tricks.com/learning-gutenberg-4-modern-javascript-syntax/)。值得注意的是，我并不是说你应该用这个代替 Redux 或 MobX。我们正在一起开发一个小项目来提升技能，嘿，如果你一直关注 JavaScript 大小，它肯定能以最小代价为小型应用程序赋能。","path":"TODO1/build-a-state-management-system-with-vanilla-javascript.md","position":18,"original_position":18,"commit_id":"721688b1adb8bcf0e475910d9046745247741d44","original_commit_id":"721688b1adb8bcf0e475910d9046745247741d44","user":{"login":"shery","id":12773365,"node_id":"MDQ6VXNlcjEyNzczMzY1","avatar_url":"https://avatars1.githubusercontent.com/u/12773365?v=4","gravatar_id":"","url":"https://api.github.com/users/shery","html_url":"https://github.com/shery","followers_url":"https://api.github.com/users/shery/followers","following_url":"https://api.github.com/users/shery/following{/other_user}","gists_url":"https://api.github.com/users/shery/gists{/gist_id}","starred_url":"https://api.github.com/users/shery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shery/subscriptions","organizations_url":"https://api.github.com/users/shery/orgs","repos_url":"https://api.github.com/users/shery/repos","events_url":"https://api.github.com/users/shery/events{/privacy}","received_events_url":"https://api.github.com/users/shery/received_events","type":"User","site_admin":false},"body":"JavaScript payload 我的理解是通过网络获取的 JavaScript 文件","created_at":"2018-08-15T15:05:27Z","updated_at":"2018-08-15T15:05:27Z","html_url":"https://github.com/xitu/gold-miner/pull/4302#discussion_r210300177","pull_request_url":"https://api.github.com/repos/xitu/gold-miner/pulls/4302","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/xitu/gold-miner/pulls/comments/210300177"},"html":{"href":"https://github.com/xitu/gold-miner/pull/4302#discussion_r210300177"},"pull_request":{"href":"https://api.github.com/repos/xitu/gold-miner/pulls/4302"}},"in_reply_to_id":210225999},"pull_request":{"url":"https://api.github.com/repos/xitu/gold-miner/pulls/4302","id":208049286,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA4MDQ5Mjg2","html_url":"https://github.com/xitu/gold-miner/pull/4302","diff_url":"https://github.com/xitu/gold-miner/pull/4302.diff","patch_url":"https://github.com/xitu/gold-miner/pull/4302.patch","issue_url":"https://api.github.com/repos/xitu/gold-miner/issues/4302","number":4302,"state":"open","locked":false,"title":"使用原生 JavaScript 构建状态管理系统","user":{"login":"shery","id":12773365,"node_id":"MDQ6VXNlcjEyNzczMzY1","avatar_url":"https://avatars1.githubusercontent.com/u/12773365?v=4","gravatar_id":"","url":"https://api.github.com/users/shery","html_url":"https://github.com/shery","followers_url":"https://api.github.com/users/shery/followers","following_url":"https://api.github.com/users/shery/following{/other_user}","gists_url":"https://api.github.com/users/shery/gists{/gist_id}","starred_url":"https://api.github.com/users/shery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shery/subscriptions","organizations_url":"https://api.github.com/users/shery/orgs","repos_url":"https://api.github.com/users/shery/repos","events_url":"https://api.github.com/users/shery/events{/privacy}","received_events_url":"https://api.github.com/users/shery/received_events","type":"User","site_admin":false},"body":"使用原生 JavaScript 构建状态管理系统\r\n\r\n译文翻译完成，resolve #4253 \r\n","created_at":"2018-08-13T17:31:25Z","updated_at":"2018-08-15T15:05:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3a3125300224f0918d2a4fa714d4c58e71cb4dd3","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":514335594,"node_id":"MDU6TGFiZWw1MTQzMzU1OTQ=","url":"https://api.github.com/repos/xitu/gold-miner/labels/%E5%89%8D%E7%AB%AF","name":"前端","color":"1d76db","default":false},{"id":322084033,"node_id":"MDU6TGFiZWwzMjIwODQwMzM=","url":"https://api.github.com/repos/xitu/gold-miner/labels/%E6%AD%A3%E5%9C%A8%E6%A0%A1%E5%AF%B9","name":"正在校对","color":"c2e0c6","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/xitu/gold-miner/pulls/4302/commits","review_comments_url":"https://api.github.com/repos/xitu/gold-miner/pulls/4302/comments","review_comment_url":"https://api.github.com/repos/xitu/gold-miner/pulls/comments{/number}","comments_url":"https://api.github.com/repos/xitu/gold-miner/issues/4302/comments","statuses_url":"https://api.github.com/repos/xitu/gold-miner/statuses/721688b1adb8bcf0e475910d9046745247741d44","head":{"label":"shery:translation/build-a-state-management-system-with-vanilla-javascript.md","ref":"translation/build-a-state-management-system-with-vanilla-javascript.md","sha":"721688b1adb8bcf0e475910d9046745247741d44","user":{"login":"shery","id":12773365,"node_id":"MDQ6VXNlcjEyNzczMzY1","avatar_url":"https://avatars1.githubusercontent.com/u/12773365?v=4","gravatar_id":"","url":"https://api.github.com/users/shery","html_url":"https://github.com/shery","followers_url":"https://api.github.com/users/shery/followers","following_url":"https://api.github.com/users/shery/following{/other_user}","gists_url":"https://api.github.com/users/shery/gists{/gist_id}","starred_url":"https://api.github.com/users/shery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shery/subscriptions","organizations_url":"https://api.github.com/users/shery/orgs","repos_url":"https://api.github.com/users/shery/repos","events_url":"https://api.github.com/users/shery/events{/privacy}","received_events_url":"https://api.github.com/users/shery/received_events","type":"User","site_admin":false},"repo":{"id":143746858,"node_id":"MDEwOlJlcG9zaXRvcnkxNDM3NDY4NTg=","name":"gold-miner","full_name":"shery/gold-miner","owner":{"login":"shery","id":12773365,"node_id":"MDQ6VXNlcjEyNzczMzY1","avatar_url":"https://avatars1.githubusercontent.com/u/12773365?v=4","gravatar_id":"","url":"https://api.github.com/users/shery","html_url":"https://github.com/shery","followers_url":"https://api.github.com/users/shery/followers","following_url":"https://api.github.com/users/shery/following{/other_user}","gists_url":"https://api.github.com/users/shery/gists{/gist_id}","starred_url":"https://api.github.com/users/shery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shery/subscriptions","organizations_url":"https://api.github.com/users/shery/orgs","repos_url":"https://api.github.com/users/shery/repos","events_url":"https://api.github.com/users/shery/events{/privacy}","received_events_url":"https://api.github.com/users/shery/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/shery/gold-miner","description":"🥇掘金翻译计划，可能是世界最大最好的英译中技术社区，最懂读者和译者的翻译平台：","fork":true,"url":"https://api.github.com/repos/shery/gold-miner","forks_url":"https://api.github.com/repos/shery/gold-miner/forks","keys_url":"https://api.github.com/repos/shery/gold-miner/keys{/key_id}","collaborators_url":"https://api.github.com/repos/shery/gold-miner/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/shery/gold-miner/teams","hooks_url":"https://api.github.com/repos/shery/gold-miner/hooks","issue_events_url":"https://api.github.com/repos/shery/gold-miner/issues/events{/number}","events_url":"https://api.github.com/repos/shery/gold-miner/events","assignees_url":"https://api.github.com/repos/shery/gold-miner/assignees{/user}","branches_url":"https://api.github.com/repos/shery/gold-miner/branches{/branch}","tags_url":"https://api.github.com/repos/shery/gold-miner/tags","blobs_url":"https://api.github.com/repos/shery/gold-miner/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/shery/gold-miner/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/shery/gold-miner/git/refs{/sha}","trees_url":"https://api.github.com/repos/shery/gold-miner/git/trees{/sha}","statuses_url":"https://api.github.com/repos/shery/gold-miner/statuses/{sha}","languages_url":"https://api.github.com/repos/shery/gold-miner/languages","stargazers_url":"https://api.github.com/repos/shery/gold-miner/stargazers","contributors_url":"https://api.github.com/repos/shery/gold-miner/contributors","subscribers_url":"https://api.github.com/repos/shery/gold-miner/subscribers","subscription_url":"https://api.github.com/repos/shery/gold-miner/subscription","commits_url":"https://api.github.com/repos/shery/gold-miner/commits{/sha}","git_commits_url":"https://api.github.com/repos/shery/gold-miner/git/commits{/sha}","comments_url":"https://api.github.com/repos/shery/gold-miner/comments{/number}","issue_comment_url":"https://api.github.com/repos/shery/gold-miner/issues/comments{/number}","contents_url":"https://api.github.com/repos/shery/gold-miner/contents/{+path}","compare_url":"https://api.github.com/repos/shery/gold-miner/compare/{base}...{head}","merges_url":"https://api.github.com/repos/shery/gold-miner/merges","archive_url":"https://api.github.com/repos/shery/gold-miner/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/shery/gold-miner/downloads","issues_url":"https://api.github.com/repos/shery/gold-miner/issues{/number}","pulls_url":"https://api.github.com/repos/shery/gold-miner/pulls{/number}","milestones_url":"https://api.github.com/repos/shery/gold-miner/milestones{/number}","notifications_url":"https://api.github.com/repos/shery/gold-miner/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/shery/gold-miner/labels{/name}","releases_url":"https://api.github.com/repos/shery/gold-miner/releases{/id}","deployments_url":"https://api.github.com/repos/shery/gold-miner/deployments","created_at":"2018-08-06T15:19:36Z","updated_at":"2018-08-06T15:19:44Z","pushed_at":"2018-08-13T17:26:57Z","git_url":"git://github.com/shery/gold-miner.git","ssh_url":"git@github.com:shery/gold-miner.git","clone_url":"https://github.com/shery/gold-miner.git","svn_url":"https://github.com/shery/gold-miner","homepage":"https://juejin.im/tag/掘金翻译计划","size":34999,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"xitu:master","ref":"master","sha":"5e3b00624b473044090e5a27429540433a53f886","user":{"login":"xitu","id":10482599,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwNDgyNTk5","avatar_url":"https://avatars2.githubusercontent.com/u/10482599?v=4","gravatar_id":"","url":"https://api.github.com/users/xitu","html_url":"https://github.com/xitu","followers_url":"https://api.github.com/users/xitu/followers","following_url":"https://api.github.com/users/xitu/following{/other_user}","gists_url":"https://api.github.com/users/xitu/gists{/gist_id}","starred_url":"https://api.github.com/users/xitu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xitu/subscriptions","organizations_url":"https://api.github.com/users/xitu/orgs","repos_url":"https://api.github.com/users/xitu/repos","events_url":"https://api.github.com/users/xitu/events{/privacy}","received_events_url":"https://api.github.com/users/xitu/received_events","type":"Organization","site_admin":false},"repo":{"id":45512989,"node_id":"MDEwOlJlcG9zaXRvcnk0NTUxMjk4OQ==","name":"gold-miner","full_name":"xitu/gold-miner","owner":{"login":"xitu","id":10482599,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwNDgyNTk5","avatar_url":"https://avatars2.githubusercontent.com/u/10482599?v=4","gravatar_id":"","url":"https://api.github.com/users/xitu","html_url":"https://github.com/xitu","followers_url":"https://api.github.com/users/xitu/followers","following_url":"https://api.github.com/users/xitu/following{/other_user}","gists_url":"https://api.github.com/users/xitu/gists{/gist_id}","starred_url":"https://api.github.com/users/xitu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xitu/subscriptions","organizations_url":"https://api.github.com/users/xitu/orgs","repos_url":"https://api.github.com/users/xitu/repos","events_url":"https://api.github.com/users/xitu/events{/privacy}","received_events_url":"https://api.github.com/users/xitu/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/xitu/gold-miner","description":"🥇掘金翻译计划，可能是世界最大最好的英译中技术社区，最懂读者和译者的翻译平台：","fork":false,"url":"https://api.github.com/repos/xitu/gold-miner","forks_url":"https://api.github.com/repos/xitu/gold-miner/forks","keys_url":"https://api.github.com/repos/xitu/gold-miner/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xitu/gold-miner/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xitu/gold-miner/teams","hooks_url":"https://api.github.com/repos/xitu/gold-miner/hooks","issue_events_url":"https://api.github.com/repos/xitu/gold-miner/issues/events{/number}","events_url":"https://api.github.com/repos/xitu/gold-miner/events","assignees_url":"https://api.github.com/repos/xitu/gold-miner/assignees{/user}","branches_url":"https://api.github.com/repos/xitu/gold-miner/branches{/branch}","tags_url":"https://api.github.com/repos/xitu/gold-miner/tags","blobs_url":"https://api.github.com/repos/xitu/gold-miner/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xitu/gold-miner/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xitu/gold-miner/git/refs{/sha}","trees_url":"https://api.github.com/repos/xitu/gold-miner/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xitu/gold-miner/statuses/{sha}","languages_url":"https://api.github.com/repos/xitu/gold-miner/languages","stargazers_url":"https://api.github.com/repos/xitu/gold-miner/stargazers","contributors_url":"https://api.github.com/repos/xitu/gold-miner/contributors","subscribers_url":"https://api.github.com/repos/xitu/gold-miner/subscribers","subscription_url":"https://api.github.com/repos/xitu/gold-miner/subscription","commits_url":"https://api.github.com/repos/xitu/gold-miner/commits{/sha}","git_commits_url":"https://api.github.com/repos/xitu/gold-miner/git/commits{/sha}","comments_url":"https://api.github.com/repos/xitu/gold-miner/comments{/number}","issue_comment_url":"https://api.github.com/repos/xitu/gold-miner/issues/comments{/number}","contents_url":"https://api.github.com/repos/xitu/gold-miner/contents/{+path}","compare_url":"https://api.github.com/repos/xitu/gold-miner/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xitu/gold-miner/merges","archive_url":"https://api.github.com/repos/xitu/gold-miner/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xitu/gold-miner/downloads","issues_url":"https://api.github.com/repos/xitu/gold-miner/issues{/number}","pulls_url":"https://api.github.com/repos/xitu/gold-miner/pulls{/number}","milestones_url":"https://api.github.com/repos/xitu/gold-miner/milestones{/number}","notifications_url":"https://api.github.com/repos/xitu/gold-miner/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xitu/gold-miner/labels{/name}","releases_url":"https://api.github.com/repos/xitu/gold-miner/releases{/id}","deployments_url":"https://api.github.com/repos/xitu/gold-miner/deployments","created_at":"2015-11-04T03:29:13Z","updated_at":"2018-08-15T13:09:33Z","pushed_at":"2018-08-15T14:08:21Z","git_url":"git://github.com/xitu/gold-miner.git","ssh_url":"git@github.com:xitu/gold-miner.git","clone_url":"https://github.com/xitu/gold-miner.git","svn_url":"https://github.com/xitu/gold-miner","homepage":"https://juejin.im/tag/掘金翻译计划","size":35351,"stargazers_count":15663,"watchers_count":15663,"language":null,"has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2709,"mirror_url":null,"archived":false,"open_issues_count":33,"license":null,"forks":2709,"open_issues":33,"watchers":15663,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/xitu/gold-miner/pulls/4302"},"html":{"href":"https://github.com/xitu/gold-miner/pull/4302"},"issue":{"href":"https://api.github.com/repos/xitu/gold-miner/issues/4302"},"comments":{"href":"https://api.github.com/repos/xitu/gold-miner/issues/4302/comments"},"review_comments":{"href":"https://api.github.com/repos/xitu/gold-miner/pulls/4302/comments"},"review_comment":{"href":"https://api.github.com/repos/xitu/gold-miner/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/xitu/gold-miner/pulls/4302/commits"},"statuses":{"href":"https://api.github.com/repos/xitu/gold-miner/statuses/721688b1adb8bcf0e475910d9046745247741d44"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"shery"}}