{"action":"opened","number":198,"pull_request":{"url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/pulls/198","id":59341067,"html_url":"https://github.com/plainblack/Lacuna-Web-Client/pull/198","diff_url":"https://github.com/plainblack/Lacuna-Web-Client/pull/198.diff","patch_url":"https://github.com/plainblack/Lacuna-Web-Client/pull/198.patch","issue_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/issues/198","number":198,"state":"open","locked":false,"title":"Stateful stores","user":{"login":"1vasari","id":1539253,"avatar_url":"https://avatars.githubusercontent.com/u/1539253?v=3","gravatar_id":"","url":"https://api.github.com/users/1vasari","html_url":"https://github.com/1vasari","followers_url":"https://api.github.com/users/1vasari/followers","following_url":"https://api.github.com/users/1vasari/following{/other_user}","gists_url":"https://api.github.com/users/1vasari/gists{/gist_id}","starred_url":"https://api.github.com/users/1vasari/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/1vasari/subscriptions","organizations_url":"https://api.github.com/users/1vasari/orgs","repos_url":"https://api.github.com/users/1vasari/repos","events_url":"https://api.github.com/users/1vasari/events{/privacy}","received_events_url":"https://api.github.com/users/1vasari/received_events","type":"User","site_admin":false},"body":"This PR implements a store mixin that allows stores to maintain their own state. We've been doing this (in various different forms) but I've now organized it all into a reusable system. \r\n\r\nHere's an example of what it looks like:\r\n\r\n```javascript\r\nvar Reflux        = require('reflux');\r\nvar StatefulStore = require('js/stores/mixins/stateful');\r\n\r\nvar clone         = require('js/util').clone;\r\n\r\nvar MyStore = Reflux.createStore({\r\n    mixins : [\r\n        StatefulStore\r\n    ],\r\n\r\n    getDefaultData : function() {\r\n        return {\r\n            foo    : 'bar',\r\n            spam   : 'eggs',\r\n            points : 10,\r\n            users  : [\r\n                'Dave',\r\n                'Bob',\r\n                'Harry'\r\n            ]\r\n        }\r\n    },\r\n\r\n    onAddUser : function(name) {\r\n        // Clone the store's state. See above for reasoning.\r\n        var state = clone(this.state);\r\n\r\n        // Modify the copied object however we deem necessary.\r\n        state.users.push(name);\r\n\r\n        // Send it out to whoever is listening.\r\n        this.emit(name);\r\n    },\r\n\r\n    clear : function() {\r\n        // This is common pattern for reseting a store back to its initial data.\r\n        this.emit(this.getDefaultData());\r\n    }\r\n});\r\n\r\n// Elsewhere...\r\n\r\nfunction somethingThatOnlyNeedsPointsOnce() {\r\n    // Note: only do this if you need something from the store once. Otherwise, you should\r\n    // listen to it and handle when the data changes.\r\n    var points = MyStore.getData().points;\r\n}\r\n```","created_at":"2016-02-15T09:53:40Z","updated_at":"2016-02-15T09:53:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/pulls/198/commits","review_comments_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/pulls/198/comments","review_comment_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/pulls/comments{/number}","comments_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/issues/198/comments","statuses_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/statuses/776d8b52c1d563976f4f5a99b3c29472e2a51edc","head":{"label":"1vasari:stateful-stores","ref":"stateful-stores","sha":"776d8b52c1d563976f4f5a99b3c29472e2a51edc","user":{"login":"1vasari","id":1539253,"avatar_url":"https://avatars.githubusercontent.com/u/1539253?v=3","gravatar_id":"","url":"https://api.github.com/users/1vasari","html_url":"https://github.com/1vasari","followers_url":"https://api.github.com/users/1vasari/followers","following_url":"https://api.github.com/users/1vasari/following{/other_user}","gists_url":"https://api.github.com/users/1vasari/gists{/gist_id}","starred_url":"https://api.github.com/users/1vasari/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/1vasari/subscriptions","organizations_url":"https://api.github.com/users/1vasari/orgs","repos_url":"https://api.github.com/users/1vasari/repos","events_url":"https://api.github.com/users/1vasari/events{/privacy}","received_events_url":"https://api.github.com/users/1vasari/received_events","type":"User","site_admin":false},"repo":{"id":43793135,"name":"Lacuna-Web-Client","full_name":"1vasari/Lacuna-Web-Client","owner":{"login":"1vasari","id":1539253,"avatar_url":"https://avatars.githubusercontent.com/u/1539253?v=3","gravatar_id":"","url":"https://api.github.com/users/1vasari","html_url":"https://github.com/1vasari","followers_url":"https://api.github.com/users/1vasari/followers","following_url":"https://api.github.com/users/1vasari/following{/other_user}","gists_url":"https://api.github.com/users/1vasari/gists{/gist_id}","starred_url":"https://api.github.com/users/1vasari/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/1vasari/subscriptions","organizations_url":"https://api.github.com/users/1vasari/orgs","repos_url":"https://api.github.com/users/1vasari/repos","events_url":"https://api.github.com/users/1vasari/events{/privacy}","received_events_url":"https://api.github.com/users/1vasari/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/1vasari/Lacuna-Web-Client","description":"The pure javascript client for The Lacuna Expanse.","fork":true,"url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client","forks_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/forks","keys_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/teams","hooks_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/hooks","issue_events_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/issues/events{/number}","events_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/events","assignees_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/assignees{/user}","branches_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/branches{/branch}","tags_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/tags","blobs_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/git/refs{/sha}","trees_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/statuses/{sha}","languages_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/languages","stargazers_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/stargazers","contributors_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/contributors","subscribers_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/subscribers","subscription_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/subscription","commits_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/commits{/sha}","git_commits_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/git/commits{/sha}","comments_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/comments{/number}","issue_comment_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/issues/comments{/number}","contents_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/contents/{+path}","compare_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/merges","archive_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/downloads","issues_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/issues{/number}","pulls_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/pulls{/number}","milestones_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/milestones{/number}","notifications_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/labels{/name}","releases_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/releases{/id}","deployments_url":"https://api.github.com/repos/1vasari/Lacuna-Web-Client/deployments","created_at":"2015-10-07T03:29:20Z","updated_at":"2016-02-11T21:13:52Z","pushed_at":"2016-02-15T09:36:39Z","git_url":"git://github.com/1vasari/Lacuna-Web-Client.git","ssh_url":"git@github.com:1vasari/Lacuna-Web-Client.git","clone_url":"https://github.com/1vasari/Lacuna-Web-Client.git","svn_url":"https://github.com/1vasari/Lacuna-Web-Client","homepage":"http://www.lacunaexpanse.com","size":27164,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"plainblack:master","ref":"master","sha":"171866d0caab92ec7d2dc7ed766b401d06061ad3","user":{"login":"plainblack","id":52236,"avatar_url":"https://avatars.githubusercontent.com/u/52236?v=3","gravatar_id":"","url":"https://api.github.com/users/plainblack","html_url":"https://github.com/plainblack","followers_url":"https://api.github.com/users/plainblack/followers","following_url":"https://api.github.com/users/plainblack/following{/other_user}","gists_url":"https://api.github.com/users/plainblack/gists{/gist_id}","starred_url":"https://api.github.com/users/plainblack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plainblack/subscriptions","organizations_url":"https://api.github.com/users/plainblack/orgs","repos_url":"https://api.github.com/users/plainblack/repos","events_url":"https://api.github.com/users/plainblack/events{/privacy}","received_events_url":"https://api.github.com/users/plainblack/received_events","type":"Organization","site_admin":false},"repo":{"id":913776,"name":"Lacuna-Web-Client","full_name":"plainblack/Lacuna-Web-Client","owner":{"login":"plainblack","id":52236,"avatar_url":"https://avatars.githubusercontent.com/u/52236?v=3","gravatar_id":"","url":"https://api.github.com/users/plainblack","html_url":"https://github.com/plainblack","followers_url":"https://api.github.com/users/plainblack/followers","following_url":"https://api.github.com/users/plainblack/following{/other_user}","gists_url":"https://api.github.com/users/plainblack/gists{/gist_id}","starred_url":"https://api.github.com/users/plainblack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plainblack/subscriptions","organizations_url":"https://api.github.com/users/plainblack/orgs","repos_url":"https://api.github.com/users/plainblack/repos","events_url":"https://api.github.com/users/plainblack/events{/privacy}","received_events_url":"https://api.github.com/users/plainblack/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/plainblack/Lacuna-Web-Client","description":"The pure javascript client for The Lacuna Expanse.","fork":false,"url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client","forks_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/forks","keys_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/teams","hooks_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/hooks","issue_events_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/issues/events{/number}","events_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/events","assignees_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/assignees{/user}","branches_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/branches{/branch}","tags_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/tags","blobs_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/git/refs{/sha}","trees_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/statuses/{sha}","languages_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/languages","stargazers_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/stargazers","contributors_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/contributors","subscribers_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/subscribers","subscription_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/subscription","commits_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/commits{/sha}","git_commits_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/git/commits{/sha}","comments_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/comments{/number}","issue_comment_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/issues/comments{/number}","contents_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/contents/{+path}","compare_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/merges","archive_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/downloads","issues_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/issues{/number}","pulls_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/pulls{/number}","milestones_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/milestones{/number}","notifications_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/labels{/name}","releases_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/releases{/id}","deployments_url":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/deployments","created_at":"2010-09-15T21:56:26Z","updated_at":"2016-02-06T18:02:20Z","pushed_at":"2016-02-15T05:22:30Z","git_url":"git://github.com/plainblack/Lacuna-Web-Client.git","ssh_url":"git@github.com:plainblack/Lacuna-Web-Client.git","clone_url":"https://github.com/plainblack/Lacuna-Web-Client.git","svn_url":"https://github.com/plainblack/Lacuna-Web-Client","homepage":"http://www.lacunaexpanse.com","size":27338,"stargazers_count":34,"watchers_count":34,"language":"JavaScript","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":32,"mirror_url":null,"open_issues_count":49,"forks":32,"open_issues":49,"watchers":34,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/pulls/198"},"html":{"href":"https://github.com/plainblack/Lacuna-Web-Client/pull/198"},"issue":{"href":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/issues/198"},"comments":{"href":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/issues/198/comments"},"review_comments":{"href":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/pulls/198/comments"},"review_comment":{"href":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/pulls/198/commits"},"statuses":{"href":"https://api.github.com/repos/plainblack/Lacuna-Web-Client/statuses/776d8b52c1d563976f4f5a99b3c29472e2a51edc"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":2,"additions":772,"deletions":642,"changed_files":28}}