{"action":"closed","number":93,"pull_request":{"url":"https://api.github.com/repos/dekujs/deku/pulls/93","id":35144159,"html_url":"https://github.com/dekujs/deku/pull/93","diff_url":"https://github.com/dekujs/deku/pull/93.diff","patch_url":"https://github.com/dekujs/deku/pull/93.patch","issue_url":"https://api.github.com/repos/dekujs/deku/issues/93","number":93,"state":"closed","locked":false,"title":"Allow hooks to return a promise to update state","user":{"login":"anthonyshort","id":36125,"avatar_url":"https://avatars.githubusercontent.com/u/36125?v=3","gravatar_id":"","url":"https://api.github.com/users/anthonyshort","html_url":"https://github.com/anthonyshort","followers_url":"https://api.github.com/users/anthonyshort/followers","following_url":"https://api.github.com/users/anthonyshort/following{/other_user}","gists_url":"https://api.github.com/users/anthonyshort/gists{/gist_id}","starred_url":"https://api.github.com/users/anthonyshort/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anthonyshort/subscriptions","organizations_url":"https://api.github.com/users/anthonyshort/orgs","repos_url":"https://api.github.com/users/anthonyshort/repos","events_url":"https://api.github.com/users/anthonyshort/events{/privacy}","received_events_url":"https://api.github.com/users/anthonyshort/received_events","type":"User","site_admin":false},"body":"I don't think this is just right yet, but it allows hooks/handlers to return a promise to update state instead of using `setState` as a function. It allows these hooks to be pure functions. Behind the scenes the resolved value of the promise is used to call `setState`, so the promise needs to resolve to an object.\r\n\r\n```\r\nfunction afterUpdate (component, prevProps, prevState) {\r\n  return request(components.props.url, function (data) {\r\n    return data.items\r\n  })\r\n}\r\n\r\nfunction onClick(e, component) {\r\n  return doSomeAsycThing(e.target.value)\r\n}\r\n```\r\n\r\nNot entirely sure of the benefit yet other than returning a value feels cleaner. \r\n\r\nIt doesn't work for `render`, because you might need to pass a callback down to a child component to update your own state later. \r\n\r\nThis is all backwards compatible and `setState` is still given to all of the functions as the last param.","created_at":"2015-05-11T16:26:57Z","updated_at":"2015-05-22T20:23:49Z","closed_at":"2015-05-22T20:23:49Z","merged_at":"2015-05-22T20:23:49Z","merge_commit_sha":"8c7d32ea955741a2342cd83ca922c8bd495e26d9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dekujs/deku/pulls/93/commits","review_comments_url":"https://api.github.com/repos/dekujs/deku/pulls/93/comments","review_comment_url":"https://api.github.com/repos/dekujs/deku/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dekujs/deku/issues/93/comments","statuses_url":"https://api.github.com/repos/dekujs/deku/statuses/9456a5b2c511cb4e2d3db27c7b39270530f7faf2","head":{"label":"dekujs:promise","ref":"promise","sha":"9456a5b2c511cb4e2d3db27c7b39270530f7faf2","user":{"login":"dekujs","id":12415915,"avatar_url":"https://avatars.githubusercontent.com/u/12415915?v=3","gravatar_id":"","url":"https://api.github.com/users/dekujs","html_url":"https://github.com/dekujs","followers_url":"https://api.github.com/users/dekujs/followers","following_url":"https://api.github.com/users/dekujs/following{/other_user}","gists_url":"https://api.github.com/users/dekujs/gists{/gist_id}","starred_url":"https://api.github.com/users/dekujs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dekujs/subscriptions","organizations_url":"https://api.github.com/users/dekujs/orgs","repos_url":"https://api.github.com/users/dekujs/repos","events_url":"https://api.github.com/users/dekujs/events{/privacy}","received_events_url":"https://api.github.com/users/dekujs/received_events","type":"Organization","site_admin":false},"repo":{"id":22746070,"name":"deku","full_name":"dekujs/deku","owner":{"login":"dekujs","id":12415915,"avatar_url":"https://avatars.githubusercontent.com/u/12415915?v=3","gravatar_id":"","url":"https://api.github.com/users/dekujs","html_url":"https://github.com/dekujs","followers_url":"https://api.github.com/users/dekujs/followers","following_url":"https://api.github.com/users/dekujs/following{/other_user}","gists_url":"https://api.github.com/users/dekujs/gists{/gist_id}","starred_url":"https://api.github.com/users/dekujs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dekujs/subscriptions","organizations_url":"https://api.github.com/users/dekujs/orgs","repos_url":"https://api.github.com/users/dekujs/repos","events_url":"https://api.github.com/users/dekujs/events{/privacy}","received_events_url":"https://api.github.com/users/dekujs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dekujs/deku","description":"Functional view library for building UI components as an alternative to React","fork":false,"url":"https://api.github.com/repos/dekujs/deku","forks_url":"https://api.github.com/repos/dekujs/deku/forks","keys_url":"https://api.github.com/repos/dekujs/deku/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dekujs/deku/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dekujs/deku/teams","hooks_url":"https://api.github.com/repos/dekujs/deku/hooks","issue_events_url":"https://api.github.com/repos/dekujs/deku/issues/events{/number}","events_url":"https://api.github.com/repos/dekujs/deku/events","assignees_url":"https://api.github.com/repos/dekujs/deku/assignees{/user}","branches_url":"https://api.github.com/repos/dekujs/deku/branches{/branch}","tags_url":"https://api.github.com/repos/dekujs/deku/tags","blobs_url":"https://api.github.com/repos/dekujs/deku/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dekujs/deku/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dekujs/deku/git/refs{/sha}","trees_url":"https://api.github.com/repos/dekujs/deku/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dekujs/deku/statuses/{sha}","languages_url":"https://api.github.com/repos/dekujs/deku/languages","stargazers_url":"https://api.github.com/repos/dekujs/deku/stargazers","contributors_url":"https://api.github.com/repos/dekujs/deku/contributors","subscribers_url":"https://api.github.com/repos/dekujs/deku/subscribers","subscription_url":"https://api.github.com/repos/dekujs/deku/subscription","commits_url":"https://api.github.com/repos/dekujs/deku/commits{/sha}","git_commits_url":"https://api.github.com/repos/dekujs/deku/git/commits{/sha}","comments_url":"https://api.github.com/repos/dekujs/deku/comments{/number}","issue_comment_url":"https://api.github.com/repos/dekujs/deku/issues/comments{/number}","contents_url":"https://api.github.com/repos/dekujs/deku/contents/{+path}","compare_url":"https://api.github.com/repos/dekujs/deku/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dekujs/deku/merges","archive_url":"https://api.github.com/repos/dekujs/deku/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dekujs/deku/downloads","issues_url":"https://api.github.com/repos/dekujs/deku/issues{/number}","pulls_url":"https://api.github.com/repos/dekujs/deku/pulls{/number}","milestones_url":"https://api.github.com/repos/dekujs/deku/milestones{/number}","notifications_url":"https://api.github.com/repos/dekujs/deku/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dekujs/deku/labels{/name}","releases_url":"https://api.github.com/repos/dekujs/deku/releases{/id}","created_at":"2014-08-08T04:32:23Z","updated_at":"2015-05-22T12:04:19Z","pushed_at":"2015-05-22T20:23:49Z","git_url":"git://github.com/dekujs/deku.git","ssh_url":"git@github.com:dekujs/deku.git","clone_url":"https://github.com/dekujs/deku.git","svn_url":"https://github.com/dekujs/deku","homepage":"","size":3926,"stargazers_count":1421,"watchers_count":1421,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":35,"mirror_url":null,"open_issues_count":13,"forks":35,"open_issues":13,"watchers":1421,"default_branch":"master"}},"base":{"label":"dekujs:master","ref":"master","sha":"ba7f62c576865e6e3b93581a491569bdb5832451","user":{"login":"dekujs","id":12415915,"avatar_url":"https://avatars.githubusercontent.com/u/12415915?v=3","gravatar_id":"","url":"https://api.github.com/users/dekujs","html_url":"https://github.com/dekujs","followers_url":"https://api.github.com/users/dekujs/followers","following_url":"https://api.github.com/users/dekujs/following{/other_user}","gists_url":"https://api.github.com/users/dekujs/gists{/gist_id}","starred_url":"https://api.github.com/users/dekujs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dekujs/subscriptions","organizations_url":"https://api.github.com/users/dekujs/orgs","repos_url":"https://api.github.com/users/dekujs/repos","events_url":"https://api.github.com/users/dekujs/events{/privacy}","received_events_url":"https://api.github.com/users/dekujs/received_events","type":"Organization","site_admin":false},"repo":{"id":22746070,"name":"deku","full_name":"dekujs/deku","owner":{"login":"dekujs","id":12415915,"avatar_url":"https://avatars.githubusercontent.com/u/12415915?v=3","gravatar_id":"","url":"https://api.github.com/users/dekujs","html_url":"https://github.com/dekujs","followers_url":"https://api.github.com/users/dekujs/followers","following_url":"https://api.github.com/users/dekujs/following{/other_user}","gists_url":"https://api.github.com/users/dekujs/gists{/gist_id}","starred_url":"https://api.github.com/users/dekujs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dekujs/subscriptions","organizations_url":"https://api.github.com/users/dekujs/orgs","repos_url":"https://api.github.com/users/dekujs/repos","events_url":"https://api.github.com/users/dekujs/events{/privacy}","received_events_url":"https://api.github.com/users/dekujs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dekujs/deku","description":"Functional view library for building UI components as an alternative to React","fork":false,"url":"https://api.github.com/repos/dekujs/deku","forks_url":"https://api.github.com/repos/dekujs/deku/forks","keys_url":"https://api.github.com/repos/dekujs/deku/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dekujs/deku/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dekujs/deku/teams","hooks_url":"https://api.github.com/repos/dekujs/deku/hooks","issue_events_url":"https://api.github.com/repos/dekujs/deku/issues/events{/number}","events_url":"https://api.github.com/repos/dekujs/deku/events","assignees_url":"https://api.github.com/repos/dekujs/deku/assignees{/user}","branches_url":"https://api.github.com/repos/dekujs/deku/branches{/branch}","tags_url":"https://api.github.com/repos/dekujs/deku/tags","blobs_url":"https://api.github.com/repos/dekujs/deku/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dekujs/deku/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dekujs/deku/git/refs{/sha}","trees_url":"https://api.github.com/repos/dekujs/deku/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dekujs/deku/statuses/{sha}","languages_url":"https://api.github.com/repos/dekujs/deku/languages","stargazers_url":"https://api.github.com/repos/dekujs/deku/stargazers","contributors_url":"https://api.github.com/repos/dekujs/deku/contributors","subscribers_url":"https://api.github.com/repos/dekujs/deku/subscribers","subscription_url":"https://api.github.com/repos/dekujs/deku/subscription","commits_url":"https://api.github.com/repos/dekujs/deku/commits{/sha}","git_commits_url":"https://api.github.com/repos/dekujs/deku/git/commits{/sha}","comments_url":"https://api.github.com/repos/dekujs/deku/comments{/number}","issue_comment_url":"https://api.github.com/repos/dekujs/deku/issues/comments{/number}","contents_url":"https://api.github.com/repos/dekujs/deku/contents/{+path}","compare_url":"https://api.github.com/repos/dekujs/deku/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dekujs/deku/merges","archive_url":"https://api.github.com/repos/dekujs/deku/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dekujs/deku/downloads","issues_url":"https://api.github.com/repos/dekujs/deku/issues{/number}","pulls_url":"https://api.github.com/repos/dekujs/deku/pulls{/number}","milestones_url":"https://api.github.com/repos/dekujs/deku/milestones{/number}","notifications_url":"https://api.github.com/repos/dekujs/deku/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dekujs/deku/labels{/name}","releases_url":"https://api.github.com/repos/dekujs/deku/releases{/id}","created_at":"2014-08-08T04:32:23Z","updated_at":"2015-05-22T12:04:19Z","pushed_at":"2015-05-22T20:23:49Z","git_url":"git://github.com/dekujs/deku.git","ssh_url":"git@github.com:dekujs/deku.git","clone_url":"https://github.com/dekujs/deku.git","svn_url":"https://github.com/dekujs/deku","homepage":"","size":3926,"stargazers_count":1421,"watchers_count":1421,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":35,"mirror_url":null,"open_issues_count":13,"forks":35,"open_issues":13,"watchers":1421,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dekujs/deku/pulls/93"},"html":{"href":"https://github.com/dekujs/deku/pull/93"},"issue":{"href":"https://api.github.com/repos/dekujs/deku/issues/93"},"comments":{"href":"https://api.github.com/repos/dekujs/deku/issues/93/comments"},"review_comments":{"href":"https://api.github.com/repos/dekujs/deku/pulls/93/comments"},"review_comment":{"href":"https://api.github.com/repos/dekujs/deku/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dekujs/deku/pulls/93/commits"},"statuses":{"href":"https://api.github.com/repos/dekujs/deku/statuses/9456a5b2c511cb4e2d3db27c7b39270530f7faf2"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"anthonyshort","id":36125,"avatar_url":"https://avatars.githubusercontent.com/u/36125?v=3","gravatar_id":"","url":"https://api.github.com/users/anthonyshort","html_url":"https://github.com/anthonyshort","followers_url":"https://api.github.com/users/anthonyshort/followers","following_url":"https://api.github.com/users/anthonyshort/following{/other_user}","gists_url":"https://api.github.com/users/anthonyshort/gists{/gist_id}","starred_url":"https://api.github.com/users/anthonyshort/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anthonyshort/subscriptions","organizations_url":"https://api.github.com/users/anthonyshort/orgs","repos_url":"https://api.github.com/users/anthonyshort/repos","events_url":"https://api.github.com/users/anthonyshort/events{/privacy}","received_events_url":"https://api.github.com/users/anthonyshort/received_events","type":"User","site_admin":false},"comments":3,"review_comments":0,"commits":4,"additions":129,"deletions":8,"changed_files":6}}