{"action":"closed","issue":{"url":"https://api.github.com/repos/Sententiaregum/flux-container/issues/22","repository_url":"https://api.github.com/repos/Sententiaregum/flux-container","labels_url":"https://api.github.com/repos/Sententiaregum/flux-container/issues/22/labels{/name}","comments_url":"https://api.github.com/repos/Sententiaregum/flux-container/issues/22/comments","events_url":"https://api.github.com/repos/Sententiaregum/flux-container/issues/22/events","html_url":"https://github.com/Sententiaregum/flux-container/issues/22","id":150824568,"number":22,"title":"make `BaseStore` private","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},"labels":[{"url":"https://api.github.com/repos/Sententiaregum/flux-container/labels/Enhancement","name":"Enhancement","color":"5319e7"},{"url":"https://api.github.com/repos/Sententiaregum/flux-container/labels/in%20review","name":"in review","color":"e6e6e6"},{"url":"https://api.github.com/repos/Sententiaregum/flux-container/labels/Topic:%20Store%20handling","name":"Topic: Store handling","color":"fbca04"}],"state":"closed","locked":false,"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":0,"closed_issues":3,"state":"open","created_at":"2016-04-25T09:34:33Z","updated_at":"2016-04-27T15:58:16Z","due_on":null,"closed_at":null},"comments":0,"created_at":"2016-04-25T11:08:51Z","updated_at":"2016-04-27T15:58:16Z","closed_at":"2016-04-27T15:58:16Z","body":"### Introduction\r\n\r\nin ``1.0.2`` the view handling has been refactored by introducing an API that listens to stores without being forced to inherit another abstract ``react`` class. Furthermore it is now possible to use any view library since the react dependency has been removed.\r\nThe second class which is public is the ``BaseStore``. It should exist internally only as the store __must__ be a dumb item handling data which has been received as payload from the dispatcher before.\r\nAllowing to create classes for the store which should be a simple, dumb entity is a too loose implementation. Therefore a factory for the store should be created returning an instance of a store.\r\n\r\n### Possible usage\r\n\r\n``` javascript\r\n// stores/FooStore.js\r\nimport { store } from 'sententiaregum-flux-container';\r\nimport BarStore from './BarStore';\r\nimport handleFooEvent from '../util/handler/handleFooEvent';\r\n\r\nexport default store(\r\n  {\r\n    'EVENT_NAME': {\r\n      params: ['values', 'from', 'dispatcher', 'payload'],\r\n      dependencies: BarStore.getToken('EVENT_NAME'),\r\n      hander: handleFooEvent\r\n    }\r\n  },\r\n  'value representing the initial state'\r\n);\r\n```\r\n\r\nThe second argument contains a default state. Sometimes is state initialization a bit trickier (fetching credentials stored in ``localStorage`` and parse it to tell the security system about the user's permissions). Therefore callbacks should be passable as initial state which return the initial state:\r\n\r\n``` javascript\r\nexport default store(\r\n  {},\r\n  () => 'any initial state created by the callback'\r\n);\r\n```\r\n\r\n### Public API of the created store\r\n\r\nThe store should contain a public API to return the state and being able to get tokens to declare dispatcher dependencies:\r\n\r\n- __getState()__ - returns the state received by the dispatcher and handled by the handler. If no dispatch cycle has been triggered, the initial state will be returned.\r\n- __getToken(eventName&lt;String&gt;)__ - returns the dispatch token for a certain event which is necessary for the declaration of dependencies.\r\n\r\nThe **_setState(newState&lt;mixed&gt;)** is used internally for internal purposes (the internal handler injects the result of the handler into the store) and is therefore considered to be internal and should not be used elsewhere. In order to ensure the internal state, this method is prefixed with an underscore. Same for **_setTokens**."}}