{"action":"opened","issue":{"url":"https://api.github.com/repos/hachibeeDI/Amamori/issues/1","repository_url":"https://api.github.com/repos/hachibeeDI/Amamori","labels_url":"https://api.github.com/repos/hachibeeDI/Amamori/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/hachibeeDI/Amamori/issues/1/comments","events_url":"https://api.github.com/repos/hachibeeDI/Amamori/issues/1/events","html_url":"https://github.com/hachibeeDI/Amamori/issues/1","id":135992779,"number":1,"title":"components should have state from store more easily","user":{"login":"hachibeeDI","id":1428294,"avatar_url":"https://avatars.githubusercontent.com/u/1428294?v=3","gravatar_id":"","url":"https://api.github.com/users/hachibeeDI","html_url":"https://github.com/hachibeeDI","followers_url":"https://api.github.com/users/hachibeeDI/followers","following_url":"https://api.github.com/users/hachibeeDI/following{/other_user}","gists_url":"https://api.github.com/users/hachibeeDI/gists{/gist_id}","starred_url":"https://api.github.com/users/hachibeeDI/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hachibeeDI/subscriptions","organizations_url":"https://api.github.com/users/hachibeeDI/orgs","repos_url":"https://api.github.com/users/hachibeeDI/repos","events_url":"https://api.github.com/users/hachibeeDI/events{/privacy}","received_events_url":"https://api.github.com/users/hachibeeDI/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-02-24T08:33:20Z","updated_at":"2016-02-24T08:33:20Z","closed_at":null,"body":"Note Just an idea:\r\n\r\n```javascript\r\n\r\nclass Component /* */ {\r\n  // component is going to have state {hoge, foo} automatically\r\n  // and store.emit('changed') will trigger the setState.\r\n  static get Stores { return {hoge: HogeStore, foo: FooStore} }\r\n  constructor(props) {\r\n    super(props)\r\n    const stores = constructor.Stores.map(this.createStore.bind(this, this.context.dispatcher))\r\n    // NOTE: need some label to apart each Store's states.\r\n    this.observes([stores]).on(subscribe('changed', state => /* */))\r\n  }\r\n}\r\n\r\nclass Store<T implements Immutable.Record> /* */ {\r\n  initState(): T { /* should override */ }\r\n  getState(): T { /* should override */ }\r\n  /* private */ setState(state) {}\r\n  update(updater: T -> T) {\r\n    const before = this.getState()\r\n    const after = updater(before)\r\n    if (before !== after) return this.emit('changed', after)\r\n  }\r\n}\r\n\r\n```\r\n\r\n"}}