{"action":"created","comment":{"url":"https://api.github.com/repos/Sententiaregum/flux-container/pulls/comments/61262965","id":61262965,"diff_hunk":"@@ -1,77 +1,107 @@\n # Stores\n \n-## Connect the store with the action\n+## How should stores look like?\n \n-### Example\n+A lot of flux examples declare stores as \"thing\" which inherits from an ``event emitter`` (usually the internal one of NodeJs)\n+and contains data received from the dispatcher, but stores should be dumb data stores and must not be responsible\n+for handling any kind of events in order to trigger changes in the view.\n+Therefore an improved concept of stores has been implemented to achieve this.\n \n-In order to avoid writing much boiler-plate code and having just a simple config, a ``connector``\n-has been implemented which connects the listeners from a store to the dispatcher:\n+## Assemble a store and hook into the one-way data flow\n+\n+The store is the instance of an internal class holding the state and created by a factory.\n+The public API of this store contains two methods:\n+\n+- __getState()__ - returns the state received and processed by the dispatcher\n+- __getToken(eventName:String)__ - returns the dispatch token of a certain event name\n+\n+The store can be created like this:\n \n ``` javascript\n-import { AppDispatcher, BaseStore } from 'sententiaregum-flux-container';\n-\n-class Store extends BaseStore {\n-  constructor() {\n-    super();\n-    this.setState({\n-      name: 'bar'\n-    });\n-  }\n+import { store } from 'sententiaregum-flux-container';\n+import storeHandler from './handlers/storeHandler';\n \n-  getSubscribedEvents() {\n-    return [\n-      {\n-        name: 'EVENT_NAME',\n-        function: (param1, param2) => {\n-          return {\n-            'name': param1,\n-            'surname': param2\n-          }\n-        },\n-        params: ['param1', 'param2']\n-      }\n-    ];\n-  }\n-}\n+export default store(\n+  {\n+    'EVENT_NAME': {\n+      function: storeHandler,\n+      params: ['payload_param_1', 'payload_param_2']\n+    }\n+  },\n+  {} // initial state (default value)\n+);\n+```\n \n-const store = new Store();\n-store.init();\n+The store creates an instance of the store by using the factory function.\n+It is able to setup subscriptions to a dispatcher. That means: if the dispatcher runs an action\n+called ``EVENT_NAME``, the callback ``storeHandler`` will be executed with the values as arguments\n+that contained the key ``payload_param_1`` and ``payload_param_2``:","path":"docs/api/stores.md","position":68,"original_position":68,"commit_id":"144eb0dd211a2f32674e434c091564abef254cbf","original_commit_id":"144eb0dd211a2f32674e434c091564abef254cbf","user":{"login":"Ma27","id":6025220,"avatar_url":"https://avatars.githubusercontent.com/u/6025220?v=3","gravatar_id":"","url":"https://api.github.com/users/Ma27","html_url":"https://github.com/Ma27","followers_url":"https://api.github.com/users/Ma27/followers","following_url":"https://api.github.com/users/Ma27/following{/other_user}","gists_url":"https://api.github.com/users/Ma27/gists{/gist_id}","starred_url":"https://api.github.com/users/Ma27/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ma27/subscriptions","organizations_url":"https://api.github.com/users/Ma27/orgs","repos_url":"https://api.github.com/users/Ma27/repos","events_url":"https://api.github.com/users/Ma27/events{/privacy}","received_events_url":"https://api.github.com/users/Ma27/received_events","type":"User","site_admin":false},"body":"make this clearer","created_at":"2016-04-27T14:07:44Z","updated_at":"2016-04-27T14:07:44Z","html_url":"https://github.com/Sententiaregum/flux-container/pull/23#discussion_r61262965","pull_request_url":"https://api.github.com/repos/Sententiaregum/flux-container/pulls/23","_links":{"self":{"href":"https://api.github.com/repos/Sententiaregum/flux-container/pulls/comments/61262965"},"html":{"href":"https://github.com/Sententiaregum/flux-container/pull/23#discussion_r61262965"},"pull_request":{"href":"https://api.github.com/repos/Sententiaregum/flux-container/pulls/23"}}},"pull_request":{"url":"https://api.github.com/repos/Sententiaregum/flux-container/pulls/23","id":68050621,"html_url":"https://github.com/Sententiaregum/flux-container/pull/23","diff_url":"https://github.com/Sententiaregum/flux-container/pull/23.diff","patch_url":"https://github.com/Sententiaregum/flux-container/pull/23.patch","issue_url":"https://api.github.com/repos/Sententiaregum/flux-container/issues/23","number":23,"state":"open","locked":false,"title":"#22 - #15 - refactor stores","user":{"login":"Ma27","id":6025220,"avatar_url":"https://avatars.githubusercontent.com/u/6025220?v=3","gravatar_id":"","url":"https://api.github.com/users/Ma27","html_url":"https://github.com/Ma27","followers_url":"https://api.github.com/users/Ma27/followers","following_url":"https://api.github.com/users/Ma27/following{/other_user}","gists_url":"https://api.github.com/users/Ma27/gists{/gist_id}","starred_url":"https://api.github.com/users/Ma27/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ma27/subscriptions","organizations_url":"https://api.github.com/users/Ma27/orgs","repos_url":"https://api.github.com/users/Ma27/repos","events_url":"https://api.github.com/users/Ma27/events{/privacy}","received_events_url":"https://api.github.com/users/Ma27/received_events","type":"User","site_admin":false},"body":"### Overview\r\n\r\nrefactored the store API:\r\n\r\n- separate emitter from store\r\n- use factory to assemble stores\r\n- simplify event subscriber configuration\r\n- support for lazy store initialization (see #15)\r\n- refactor internal API of the connector\r\n- node v6\r\n### Related/Resolved tickets\r\n\r\nresolves #22 \r\nresolves #15 ","created_at":"2016-04-27T13:12:21Z","updated_at":"2016-04-27T14:07:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"946037f1b80f6df9aaa5b6979510def71898610a","assignee":{"login":"Ma27","id":6025220,"avatar_url":"https://avatars.githubusercontent.com/u/6025220?v=3","gravatar_id":"","url":"https://api.github.com/users/Ma27","html_url":"https://github.com/Ma27","followers_url":"https://api.github.com/users/Ma27/followers","following_url":"https://api.github.com/users/Ma27/following{/other_user}","gists_url":"https://api.github.com/users/Ma27/gists{/gist_id}","starred_url":"https://api.github.com/users/Ma27/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ma27/subscriptions","organizations_url":"https://api.github.com/users/Ma27/orgs","repos_url":"https://api.github.com/users/Ma27/repos","events_url":"https://api.github.com/users/Ma27/events{/privacy}","received_events_url":"https://api.github.com/users/Ma27/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/Sententiaregum/flux-container/milestones/4","html_url":"https://github.com/Sententiaregum/flux-container/milestones/1.0.3","labels_url":"https://api.github.com/repos/Sententiaregum/flux-container/milestones/4/labels","id":1728532,"number":4,"title":"1.0.3","description":"","creator":{"login":"Ma27","id":6025220,"avatar_url":"https://avatars.githubusercontent.com/u/6025220?v=3","gravatar_id":"","url":"https://api.github.com/users/Ma27","html_url":"https://github.com/Ma27","followers_url":"https://api.github.com/users/Ma27/followers","following_url":"https://api.github.com/users/Ma27/following{/other_user}","gists_url":"https://api.github.com/users/Ma27/gists{/gist_id}","starred_url":"https://api.github.com/users/Ma27/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ma27/subscriptions","organizations_url":"https://api.github.com/users/Ma27/orgs","repos_url":"https://api.github.com/users/Ma27/repos","events_url":"https://api.github.com/users/Ma27/events{/privacy}","received_events_url":"https://api.github.com/users/Ma27/received_events","type":"User","site_admin":false},"open_issues":3,"closed_issues":0,"state":"open","created_at":"2016-04-25T09:34:33Z","updated_at":"2016-04-27T13:13:16Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/Sententiaregum/flux-container/pulls/23/commits","review_comments_url":"https://api.github.com/repos/Sententiaregum/flux-container/pulls/23/comments","review_comment_url":"https://api.github.com/repos/Sententiaregum/flux-container/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Sententiaregum/flux-container/issues/23/comments","statuses_url":"https://api.github.com/repos/Sententiaregum/flux-container/statuses/144eb0dd211a2f32674e434c091564abef254cbf","head":{"label":"Sententiaregum:#22-store-refactoring","ref":"#22-store-refactoring","sha":"144eb0dd211a2f32674e434c091564abef254cbf","user":{"login":"Sententiaregum","id":14262478,"avatar_url":"https://avatars.githubusercontent.com/u/14262478?v=3","gravatar_id":"","url":"https://api.github.com/users/Sententiaregum","html_url":"https://github.com/Sententiaregum","followers_url":"https://api.github.com/users/Sententiaregum/followers","following_url":"https://api.github.com/users/Sententiaregum/following{/other_user}","gists_url":"https://api.github.com/users/Sententiaregum/gists{/gist_id}","starred_url":"https://api.github.com/users/Sententiaregum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sententiaregum/subscriptions","organizations_url":"https://api.github.com/users/Sententiaregum/orgs","repos_url":"https://api.github.com/users/Sententiaregum/repos","events_url":"https://api.github.com/users/Sententiaregum/events{/privacy}","received_events_url":"https://api.github.com/users/Sententiaregum/received_events","type":"Organization","site_admin":false},"repo":{"id":54397470,"name":"flux-container","full_name":"Sententiaregum/flux-container","owner":{"login":"Sententiaregum","id":14262478,"avatar_url":"https://avatars.githubusercontent.com/u/14262478?v=3","gravatar_id":"","url":"https://api.github.com/users/Sententiaregum","html_url":"https://github.com/Sententiaregum","followers_url":"https://api.github.com/users/Sententiaregum/followers","following_url":"https://api.github.com/users/Sententiaregum/following{/other_user}","gists_url":"https://api.github.com/users/Sententiaregum/gists{/gist_id}","starred_url":"https://api.github.com/users/Sententiaregum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sententiaregum/subscriptions","organizations_url":"https://api.github.com/users/Sententiaregum/orgs","repos_url":"https://api.github.com/users/Sententiaregum/repos","events_url":"https://api.github.com/users/Sententiaregum/events{/privacy}","received_events_url":"https://api.github.com/users/Sententiaregum/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Sententiaregum/flux-container","description":"Flux implementation of sententiaregum based on a custom dispatcher","fork":false,"url":"https://api.github.com/repos/Sententiaregum/flux-container","forks_url":"https://api.github.com/repos/Sententiaregum/flux-container/forks","keys_url":"https://api.github.com/repos/Sententiaregum/flux-container/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Sententiaregum/flux-container/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Sententiaregum/flux-container/teams","hooks_url":"https://api.github.com/repos/Sententiaregum/flux-container/hooks","issue_events_url":"https://api.github.com/repos/Sententiaregum/flux-container/issues/events{/number}","events_url":"https://api.github.com/repos/Sententiaregum/flux-container/events","assignees_url":"https://api.github.com/repos/Sententiaregum/flux-container/assignees{/user}","branches_url":"https://api.github.com/repos/Sententiaregum/flux-container/branches{/branch}","tags_url":"https://api.github.com/repos/Sententiaregum/flux-container/tags","blobs_url":"https://api.github.com/repos/Sententiaregum/flux-container/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Sententiaregum/flux-container/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Sententiaregum/flux-container/git/refs{/sha}","trees_url":"https://api.github.com/repos/Sententiaregum/flux-container/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Sententiaregum/flux-container/statuses/{sha}","languages_url":"https://api.github.com/repos/Sententiaregum/flux-container/languages","stargazers_url":"https://api.github.com/repos/Sententiaregum/flux-container/stargazers","contributors_url":"https://api.github.com/repos/Sententiaregum/flux-container/contributors","subscribers_url":"https://api.github.com/repos/Sententiaregum/flux-container/subscribers","subscription_url":"https://api.github.com/repos/Sententiaregum/flux-container/subscription","commits_url":"https://api.github.com/repos/Sententiaregum/flux-container/commits{/sha}","git_commits_url":"https://api.github.com/repos/Sententiaregum/flux-container/git/commits{/sha}","comments_url":"https://api.github.com/repos/Sententiaregum/flux-container/comments{/number}","issue_comment_url":"https://api.github.com/repos/Sententiaregum/flux-container/issues/comments{/number}","contents_url":"https://api.github.com/repos/Sententiaregum/flux-container/contents/{+path}","compare_url":"https://api.github.com/repos/Sententiaregum/flux-container/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Sententiaregum/flux-container/merges","archive_url":"https://api.github.com/repos/Sententiaregum/flux-container/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Sententiaregum/flux-container/downloads","issues_url":"https://api.github.com/repos/Sententiaregum/flux-container/issues{/number}","pulls_url":"https://api.github.com/repos/Sententiaregum/flux-container/pulls{/number}","milestones_url":"https://api.github.com/repos/Sententiaregum/flux-container/milestones{/number}","notifications_url":"https://api.github.com/repos/Sententiaregum/flux-container/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Sententiaregum/flux-container/labels{/name}","releases_url":"https://api.github.com/repos/Sententiaregum/flux-container/releases{/id}","deployments_url":"https://api.github.com/repos/Sententiaregum/flux-container/deployments","created_at":"2016-03-21T14:50:40Z","updated_at":"2016-04-01T23:39:53Z","pushed_at":"2016-04-27T13:12:21Z","git_url":"git://github.com/Sententiaregum/flux-container.git","ssh_url":"git@github.com:Sententiaregum/flux-container.git","clone_url":"https://github.com/Sententiaregum/flux-container.git","svn_url":"https://github.com/Sententiaregum/flux-container","homepage":"","size":74,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":2,"default_branch":"master"}},"base":{"label":"Sententiaregum:master","ref":"master","sha":"0ed07ff0fa06f9f1406a9b178c2d849379f11676","user":{"login":"Sententiaregum","id":14262478,"avatar_url":"https://avatars.githubusercontent.com/u/14262478?v=3","gravatar_id":"","url":"https://api.github.com/users/Sententiaregum","html_url":"https://github.com/Sententiaregum","followers_url":"https://api.github.com/users/Sententiaregum/followers","following_url":"https://api.github.com/users/Sententiaregum/following{/other_user}","gists_url":"https://api.github.com/users/Sententiaregum/gists{/gist_id}","starred_url":"https://api.github.com/users/Sententiaregum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sententiaregum/subscriptions","organizations_url":"https://api.github.com/users/Sententiaregum/orgs","repos_url":"https://api.github.com/users/Sententiaregum/repos","events_url":"https://api.github.com/users/Sententiaregum/events{/privacy}","received_events_url":"https://api.github.com/users/Sententiaregum/received_events","type":"Organization","site_admin":false},"repo":{"id":54397470,"name":"flux-container","full_name":"Sententiaregum/flux-container","owner":{"login":"Sententiaregum","id":14262478,"avatar_url":"https://avatars.githubusercontent.com/u/14262478?v=3","gravatar_id":"","url":"https://api.github.com/users/Sententiaregum","html_url":"https://github.com/Sententiaregum","followers_url":"https://api.github.com/users/Sententiaregum/followers","following_url":"https://api.github.com/users/Sententiaregum/following{/other_user}","gists_url":"https://api.github.com/users/Sententiaregum/gists{/gist_id}","starred_url":"https://api.github.com/users/Sententiaregum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sententiaregum/subscriptions","organizations_url":"https://api.github.com/users/Sententiaregum/orgs","repos_url":"https://api.github.com/users/Sententiaregum/repos","events_url":"https://api.github.com/users/Sententiaregum/events{/privacy}","received_events_url":"https://api.github.com/users/Sententiaregum/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Sententiaregum/flux-container","description":"Flux implementation of sententiaregum based on a custom dispatcher","fork":false,"url":"https://api.github.com/repos/Sententiaregum/flux-container","forks_url":"https://api.github.com/repos/Sententiaregum/flux-container/forks","keys_url":"https://api.github.com/repos/Sententiaregum/flux-container/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Sententiaregum/flux-container/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Sententiaregum/flux-container/teams","hooks_url":"https://api.github.com/repos/Sententiaregum/flux-container/hooks","issue_events_url":"https://api.github.com/repos/Sententiaregum/flux-container/issues/events{/number}","events_url":"https://api.github.com/repos/Sententiaregum/flux-container/events","assignees_url":"https://api.github.com/repos/Sententiaregum/flux-container/assignees{/user}","branches_url":"https://api.github.com/repos/Sententiaregum/flux-container/branches{/branch}","tags_url":"https://api.github.com/repos/Sententiaregum/flux-container/tags","blobs_url":"https://api.github.com/repos/Sententiaregum/flux-container/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Sententiaregum/flux-container/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Sententiaregum/flux-container/git/refs{/sha}","trees_url":"https://api.github.com/repos/Sententiaregum/flux-container/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Sententiaregum/flux-container/statuses/{sha}","languages_url":"https://api.github.com/repos/Sententiaregum/flux-container/languages","stargazers_url":"https://api.github.com/repos/Sententiaregum/flux-container/stargazers","contributors_url":"https://api.github.com/repos/Sententiaregum/flux-container/contributors","subscribers_url":"https://api.github.com/repos/Sententiaregum/flux-container/subscribers","subscription_url":"https://api.github.com/repos/Sententiaregum/flux-container/subscription","commits_url":"https://api.github.com/repos/Sententiaregum/flux-container/commits{/sha}","git_commits_url":"https://api.github.com/repos/Sententiaregum/flux-container/git/commits{/sha}","comments_url":"https://api.github.com/repos/Sententiaregum/flux-container/comments{/number}","issue_comment_url":"https://api.github.com/repos/Sententiaregum/flux-container/issues/comments{/number}","contents_url":"https://api.github.com/repos/Sententiaregum/flux-container/contents/{+path}","compare_url":"https://api.github.com/repos/Sententiaregum/flux-container/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Sententiaregum/flux-container/merges","archive_url":"https://api.github.com/repos/Sententiaregum/flux-container/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Sententiaregum/flux-container/downloads","issues_url":"https://api.github.com/repos/Sententiaregum/flux-container/issues{/number}","pulls_url":"https://api.github.com/repos/Sententiaregum/flux-container/pulls{/number}","milestones_url":"https://api.github.com/repos/Sententiaregum/flux-container/milestones{/number}","notifications_url":"https://api.github.com/repos/Sententiaregum/flux-container/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Sententiaregum/flux-container/labels{/name}","releases_url":"https://api.github.com/repos/Sententiaregum/flux-container/releases{/id}","deployments_url":"https://api.github.com/repos/Sententiaregum/flux-container/deployments","created_at":"2016-03-21T14:50:40Z","updated_at":"2016-04-01T23:39:53Z","pushed_at":"2016-04-27T13:12:21Z","git_url":"git://github.com/Sententiaregum/flux-container.git","ssh_url":"git@github.com:Sententiaregum/flux-container.git","clone_url":"https://github.com/Sententiaregum/flux-container.git","svn_url":"https://github.com/Sententiaregum/flux-container","homepage":"","size":74,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Sententiaregum/flux-container/pulls/23"},"html":{"href":"https://github.com/Sententiaregum/flux-container/pull/23"},"issue":{"href":"https://api.github.com/repos/Sententiaregum/flux-container/issues/23"},"comments":{"href":"https://api.github.com/repos/Sententiaregum/flux-container/issues/23/comments"},"review_comments":{"href":"https://api.github.com/repos/Sententiaregum/flux-container/pulls/23/comments"},"review_comment":{"href":"https://api.github.com/repos/Sententiaregum/flux-container/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Sententiaregum/flux-container/pulls/23/commits"},"statuses":{"href":"https://api.github.com/repos/Sententiaregum/flux-container/statuses/144eb0dd211a2f32674e434c091564abef254cbf"}}}}