{"action":"created","comment":{"url":"https://api.github.com/repos/emberjs/guides/pulls/comments/49633433","id":49633433,"diff_hunk":"@@ -156,3 +190,191 @@ a function instead.\n Actions in components allow you to\n decouple an event happening from how it's handled, leading to modular,\n more reusable components.\n+\n+## Handling Action Completion\n+\n+Often actions perform asynchronous tasks, such as making an ajax request to a server.\n+Since actions are functions that can be passed in by a parent component, they are able to return values when called.\n+The most common scenario is for an action to return a promise so that the component can handle the action's completion.\n+\n+In our user `button-with-confirmation` component we want to leave the confirmation modal open until we know that the\n+operation has completed successfully.\n+This is accomplished by expecting a promise to be returned from `onConfirm`.\n+Upon resolution of the promise, we set a property used to indicate the visibility of the confirmation modal.\n+\n+```app/components/button-with-confirmation.js\n+export default Ember.Component.extend({\n+\n+  actions: {\n+    launchConfirmDialog() {\n+      this.set('confirmShown', true);\n+    },\n+\n+    submitConfirm() {\n+      //call onConfirm with the value of the input field as an argument\n+      this.get('onConfirm')().then() => {\n+        this.set('confirmShown', false);\n+      };\n+    },\n+\n+    cancelConfirm() {\n+      this.set('confirmShown', false);\n+    }\n+  }\n+});\n+```\n+\n+## Passing Arguments\n+\n+Actions passed to a component may be invoked with arguments.\n+In the `send-message` component, we want to provide a message type to send to the action.\n+\n+```app/templates/components/send-message.hbs\n+{{button-with-confirmation text=\"Click to send your message.\" onConfirm=(action 'sendMessage' 'info')}}","path":"source/components/triggering-changes-with-actions.md","position":117,"original_position":117,"commit_id":"c974ae6537a8c59d74f5b7c33b84eda3f82325c5","original_commit_id":"c974ae6537a8c59d74f5b7c33b84eda3f82325c5","user":{"login":"knownasilya","id":34726,"avatar_url":"https://avatars.githubusercontent.com/u/34726?v=3","gravatar_id":"","url":"https://api.github.com/users/knownasilya","html_url":"https://github.com/knownasilya","followers_url":"https://api.github.com/users/knownasilya/followers","following_url":"https://api.github.com/users/knownasilya/following{/other_user}","gists_url":"https://api.github.com/users/knownasilya/gists{/gist_id}","starred_url":"https://api.github.com/users/knownasilya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/knownasilya/subscriptions","organizations_url":"https://api.github.com/users/knownasilya/orgs","repos_url":"https://api.github.com/users/knownasilya/repos","events_url":"https://api.github.com/users/knownasilya/events{/privacy}","received_events_url":"https://api.github.com/users/knownasilya/received_events","type":"User","site_admin":false},"body":"Use quotes consistently in text and action here.","created_at":"2016-01-13T18:58:17Z","updated_at":"2016-01-13T18:58:17Z","html_url":"https://github.com/emberjs/guides/pull/1148#discussion_r49633433","pull_request_url":"https://api.github.com/repos/emberjs/guides/pulls/1148","_links":{"self":{"href":"https://api.github.com/repos/emberjs/guides/pulls/comments/49633433"},"html":{"href":"https://github.com/emberjs/guides/pull/1148#discussion_r49633433"},"pull_request":{"href":"https://api.github.com/repos/emberjs/guides/pulls/1148"}}},"pull_request":{"url":"https://api.github.com/repos/emberjs/guides/pulls/1148","id":55362602,"html_url":"https://github.com/emberjs/guides/pull/1148","diff_url":"https://github.com/emberjs/guides/pull/1148.diff","patch_url":"https://github.com/emberjs/guides/pull/1148.patch","issue_url":"https://api.github.com/repos/emberjs/guides/issues/1148","number":1148,"state":"open","locked":false,"title":"issue #853 document passing args, currying, return values, target, value","user":{"login":"toddjordan","id":3609063,"avatar_url":"https://avatars.githubusercontent.com/u/3609063?v=3","gravatar_id":"","url":"https://api.github.com/users/toddjordan","html_url":"https://github.com/toddjordan","followers_url":"https://api.github.com/users/toddjordan/followers","following_url":"https://api.github.com/users/toddjordan/following{/other_user}","gists_url":"https://api.github.com/users/toddjordan/gists{/gist_id}","starred_url":"https://api.github.com/users/toddjordan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toddjordan/subscriptions","organizations_url":"https://api.github.com/users/toddjordan/orgs","repos_url":"https://api.github.com/users/toddjordan/repos","events_url":"https://api.github.com/users/toddjordan/events{/privacy}","received_events_url":"https://api.github.com/users/toddjordan/received_events","type":"User","site_admin":false},"body":"I expanded the example a bit to take the mystery out of the confirm() function, so that I could show some of the more advanced closure action features. ","created_at":"2016-01-07T17:04:33Z","updated_at":"2016-01-13T18:58:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fc8bf02ffe6ba609c89689f65bb4b926b9f2d698","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/emberjs/guides/pulls/1148/commits","review_comments_url":"https://api.github.com/repos/emberjs/guides/pulls/1148/comments","review_comment_url":"https://api.github.com/repos/emberjs/guides/pulls/comments{/number}","comments_url":"https://api.github.com/repos/emberjs/guides/issues/1148/comments","statuses_url":"https://api.github.com/repos/emberjs/guides/statuses/c974ae6537a8c59d74f5b7c33b84eda3f82325c5","head":{"label":"toddjordan:add-additional-closure-action-doc","ref":"add-additional-closure-action-doc","sha":"c974ae6537a8c59d74f5b7c33b84eda3f82325c5","user":{"login":"toddjordan","id":3609063,"avatar_url":"https://avatars.githubusercontent.com/u/3609063?v=3","gravatar_id":"","url":"https://api.github.com/users/toddjordan","html_url":"https://github.com/toddjordan","followers_url":"https://api.github.com/users/toddjordan/followers","following_url":"https://api.github.com/users/toddjordan/following{/other_user}","gists_url":"https://api.github.com/users/toddjordan/gists{/gist_id}","starred_url":"https://api.github.com/users/toddjordan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toddjordan/subscriptions","organizations_url":"https://api.github.com/users/toddjordan/orgs","repos_url":"https://api.github.com/users/toddjordan/repos","events_url":"https://api.github.com/users/toddjordan/events{/privacy}","received_events_url":"https://api.github.com/users/toddjordan/received_events","type":"User","site_admin":false},"repo":{"id":39234886,"name":"guides","full_name":"toddjordan/guides","owner":{"login":"toddjordan","id":3609063,"avatar_url":"https://avatars.githubusercontent.com/u/3609063?v=3","gravatar_id":"","url":"https://api.github.com/users/toddjordan","html_url":"https://github.com/toddjordan","followers_url":"https://api.github.com/users/toddjordan/followers","following_url":"https://api.github.com/users/toddjordan/following{/other_user}","gists_url":"https://api.github.com/users/toddjordan/gists{/gist_id}","starred_url":"https://api.github.com/users/toddjordan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toddjordan/subscriptions","organizations_url":"https://api.github.com/users/toddjordan/orgs","repos_url":"https://api.github.com/users/toddjordan/repos","events_url":"https://api.github.com/users/toddjordan/events{/privacy}","received_events_url":"https://api.github.com/users/toddjordan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/toddjordan/guides","description":"The source for http://guides.emberjs.com","fork":true,"url":"https://api.github.com/repos/toddjordan/guides","forks_url":"https://api.github.com/repos/toddjordan/guides/forks","keys_url":"https://api.github.com/repos/toddjordan/guides/keys{/key_id}","collaborators_url":"https://api.github.com/repos/toddjordan/guides/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/toddjordan/guides/teams","hooks_url":"https://api.github.com/repos/toddjordan/guides/hooks","issue_events_url":"https://api.github.com/repos/toddjordan/guides/issues/events{/number}","events_url":"https://api.github.com/repos/toddjordan/guides/events","assignees_url":"https://api.github.com/repos/toddjordan/guides/assignees{/user}","branches_url":"https://api.github.com/repos/toddjordan/guides/branches{/branch}","tags_url":"https://api.github.com/repos/toddjordan/guides/tags","blobs_url":"https://api.github.com/repos/toddjordan/guides/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/toddjordan/guides/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/toddjordan/guides/git/refs{/sha}","trees_url":"https://api.github.com/repos/toddjordan/guides/git/trees{/sha}","statuses_url":"https://api.github.com/repos/toddjordan/guides/statuses/{sha}","languages_url":"https://api.github.com/repos/toddjordan/guides/languages","stargazers_url":"https://api.github.com/repos/toddjordan/guides/stargazers","contributors_url":"https://api.github.com/repos/toddjordan/guides/contributors","subscribers_url":"https://api.github.com/repos/toddjordan/guides/subscribers","subscription_url":"https://api.github.com/repos/toddjordan/guides/subscription","commits_url":"https://api.github.com/repos/toddjordan/guides/commits{/sha}","git_commits_url":"https://api.github.com/repos/toddjordan/guides/git/commits{/sha}","comments_url":"https://api.github.com/repos/toddjordan/guides/comments{/number}","issue_comment_url":"https://api.github.com/repos/toddjordan/guides/issues/comments{/number}","contents_url":"https://api.github.com/repos/toddjordan/guides/contents/{+path}","compare_url":"https://api.github.com/repos/toddjordan/guides/compare/{base}...{head}","merges_url":"https://api.github.com/repos/toddjordan/guides/merges","archive_url":"https://api.github.com/repos/toddjordan/guides/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/toddjordan/guides/downloads","issues_url":"https://api.github.com/repos/toddjordan/guides/issues{/number}","pulls_url":"https://api.github.com/repos/toddjordan/guides/pulls{/number}","milestones_url":"https://api.github.com/repos/toddjordan/guides/milestones{/number}","notifications_url":"https://api.github.com/repos/toddjordan/guides/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/toddjordan/guides/labels{/name}","releases_url":"https://api.github.com/repos/toddjordan/guides/releases{/id}","created_at":"2015-07-17T04:29:07Z","updated_at":"2015-12-17T01:32:27Z","pushed_at":"2016-01-13T18:44:15Z","git_url":"git://github.com/toddjordan/guides.git","ssh_url":"git@github.com:toddjordan/guides.git","clone_url":"https://github.com/toddjordan/guides.git","svn_url":"https://github.com/toddjordan/guides","homepage":null,"size":27013,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"emberjs:master","ref":"master","sha":"bf72512509317e1f25ad2cb18c2cb2280c566005","user":{"login":"emberjs","id":1253363,"avatar_url":"https://avatars.githubusercontent.com/u/1253363?v=3","gravatar_id":"","url":"https://api.github.com/users/emberjs","html_url":"https://github.com/emberjs","followers_url":"https://api.github.com/users/emberjs/followers","following_url":"https://api.github.com/users/emberjs/following{/other_user}","gists_url":"https://api.github.com/users/emberjs/gists{/gist_id}","starred_url":"https://api.github.com/users/emberjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emberjs/subscriptions","organizations_url":"https://api.github.com/users/emberjs/orgs","repos_url":"https://api.github.com/users/emberjs/repos","events_url":"https://api.github.com/users/emberjs/events{/privacy}","received_events_url":"https://api.github.com/users/emberjs/received_events","type":"Organization","site_admin":false},"repo":{"id":22767401,"name":"guides","full_name":"emberjs/guides","owner":{"login":"emberjs","id":1253363,"avatar_url":"https://avatars.githubusercontent.com/u/1253363?v=3","gravatar_id":"","url":"https://api.github.com/users/emberjs","html_url":"https://github.com/emberjs","followers_url":"https://api.github.com/users/emberjs/followers","following_url":"https://api.github.com/users/emberjs/following{/other_user}","gists_url":"https://api.github.com/users/emberjs/gists{/gist_id}","starred_url":"https://api.github.com/users/emberjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emberjs/subscriptions","organizations_url":"https://api.github.com/users/emberjs/orgs","repos_url":"https://api.github.com/users/emberjs/repos","events_url":"https://api.github.com/users/emberjs/events{/privacy}","received_events_url":"https://api.github.com/users/emberjs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/emberjs/guides","description":"The source for http://guides.emberjs.com","fork":false,"url":"https://api.github.com/repos/emberjs/guides","forks_url":"https://api.github.com/repos/emberjs/guides/forks","keys_url":"https://api.github.com/repos/emberjs/guides/keys{/key_id}","collaborators_url":"https://api.github.com/repos/emberjs/guides/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/emberjs/guides/teams","hooks_url":"https://api.github.com/repos/emberjs/guides/hooks","issue_events_url":"https://api.github.com/repos/emberjs/guides/issues/events{/number}","events_url":"https://api.github.com/repos/emberjs/guides/events","assignees_url":"https://api.github.com/repos/emberjs/guides/assignees{/user}","branches_url":"https://api.github.com/repos/emberjs/guides/branches{/branch}","tags_url":"https://api.github.com/repos/emberjs/guides/tags","blobs_url":"https://api.github.com/repos/emberjs/guides/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/emberjs/guides/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/emberjs/guides/git/refs{/sha}","trees_url":"https://api.github.com/repos/emberjs/guides/git/trees{/sha}","statuses_url":"https://api.github.com/repos/emberjs/guides/statuses/{sha}","languages_url":"https://api.github.com/repos/emberjs/guides/languages","stargazers_url":"https://api.github.com/repos/emberjs/guides/stargazers","contributors_url":"https://api.github.com/repos/emberjs/guides/contributors","subscribers_url":"https://api.github.com/repos/emberjs/guides/subscribers","subscription_url":"https://api.github.com/repos/emberjs/guides/subscription","commits_url":"https://api.github.com/repos/emberjs/guides/commits{/sha}","git_commits_url":"https://api.github.com/repos/emberjs/guides/git/commits{/sha}","comments_url":"https://api.github.com/repos/emberjs/guides/comments{/number}","issue_comment_url":"https://api.github.com/repos/emberjs/guides/issues/comments{/number}","contents_url":"https://api.github.com/repos/emberjs/guides/contents/{+path}","compare_url":"https://api.github.com/repos/emberjs/guides/compare/{base}...{head}","merges_url":"https://api.github.com/repos/emberjs/guides/merges","archive_url":"https://api.github.com/repos/emberjs/guides/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/emberjs/guides/downloads","issues_url":"https://api.github.com/repos/emberjs/guides/issues{/number}","pulls_url":"https://api.github.com/repos/emberjs/guides/pulls{/number}","milestones_url":"https://api.github.com/repos/emberjs/guides/milestones{/number}","notifications_url":"https://api.github.com/repos/emberjs/guides/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/emberjs/guides/labels{/name}","releases_url":"https://api.github.com/repos/emberjs/guides/releases{/id}","created_at":"2014-08-08T18:25:02Z","updated_at":"2016-01-11T14:39:30Z","pushed_at":"2016-01-13T18:53:10Z","git_url":"git://github.com/emberjs/guides.git","ssh_url":"git@github.com:emberjs/guides.git","clone_url":"https://github.com/emberjs/guides.git","svn_url":"https://github.com/emberjs/guides","homepage":null,"size":28116,"stargazers_count":170,"watchers_count":170,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":541,"mirror_url":null,"open_issues_count":47,"forks":541,"open_issues":47,"watchers":170,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/emberjs/guides/pulls/1148"},"html":{"href":"https://github.com/emberjs/guides/pull/1148"},"issue":{"href":"https://api.github.com/repos/emberjs/guides/issues/1148"},"comments":{"href":"https://api.github.com/repos/emberjs/guides/issues/1148/comments"},"review_comments":{"href":"https://api.github.com/repos/emberjs/guides/pulls/1148/comments"},"review_comment":{"href":"https://api.github.com/repos/emberjs/guides/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/emberjs/guides/pulls/1148/commits"},"statuses":{"href":"https://api.github.com/repos/emberjs/guides/statuses/c974ae6537a8c59d74f5b7c33b84eda3f82325c5"}}}}