{"action":"created","comment":{"url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/pulls/comments/23958176","id":23958176,"diff_hunk":"@@ -75,6 +75,75 @@ Synchronize = ReactiveCommand.CreateAsyncObservable(\n \n When a `ReactiveCommand`'s implementation is too large or too complex for an anonymous delegate, name the implementation's method the same name as the command, but with `Impl` suffixed (for example, `SychronizeImpl` above).\n \n+### Async Commands\n+\n+Prefer using async `ReactiveCommand`'s over the more basic `ReactiveCommand` for all but the most simple tasks. In ReactiveUI, you should never put Interesting™ code inside the Subscribe block - Subscribe is solely to log the result of operations, or to wire up properties to other properties.\n+\n+__Do__\n+\n+```csharp\n+// In XAML\n+<Button Command=\"{Binding Delete}\" .../>\n+\n+public class RepositoryViewModel : ReactiveObject\n+{\n+  public RepositoryViewModel() \n+  {\n+    Delete = ReactiveCommand.CreateAsyncObservable(x => DeleteImpl());\n+    Delete.IsExecuting.ToProperty(this, x => x.IsDeleting, out _isDeleting);\n+    Delete.ThrownExceptions.Subscribe(ex => this.Log().ErrorException(\"Something went wrong\", ex));\n+  }\n+\n+  public ReactiveCommand<Unit> Delete { get; private set; }\n+  \n+  readonly ObservableAsPropertyHelper<bool> _isDeleting;\n+  public bool IsDeleting { get { return _isDeleting.Value; } }\n+\n+  public IObservable<Unit> DeleteImpl()\n+  {\n+    return Observable.Start(() => /* ... */);\n+  }\n+}\n+```\n+\n+__Don't__\n+\n+```csharp\n+// In XAML\n+<Button Command=\"{Binding Delete}\" .../>\n+\n+public class RepositoryViewModel : ReactiveObject\n+{\n+  public RepositoryViewModel() \n+  {\n+    Delete = ReactiveCommand.Create();\n+    // This will block the UI thread while DeleteImpl runs\n+    Delete.Subscribe(async _ => await DeleteImpl());\n+    // These will not do what you expect\n+    Delete.IsExecuting.ToProperty(this, x => x.IsDeleting, out _isDeleting);\n+    Delete.ThrownExceptions.Subscribe(ex => this.Log().ErrorException(\"Something went wrong\", ex));\n+  }\n+\n+  public ReactiveCommand<object> Delete { get; private set; }\n+  \n+  readonly ObservableAsPropertyHelper<bool> _isDeleting;\n+  public bool IsDeleting { get { return _isDeleting.Value; } }\n+\n+  public IObservable<Unit> DeleteImpl()\n+  {\n+    return Observable.Start(() => /* ... */);\n+  }\n+}\n+```\n+\n+#### Why\n+\n+A lot of the power of `ReactiveCommand` comes from the async version. In the basic version the following features do not function as expected:\n+\n+* `IsExecuting` observable does not include any user code.","path":"README.md","position":69,"original_position":69,"commit_id":"c44d5b00084964ad661dcfee91438d29218e8ee7","original_commit_id":"c44d5b00084964ad661dcfee91438d29218e8ee7","user":{"login":"shiftkey","id":359239,"avatar_url":"https://avatars.githubusercontent.com/u/359239?v=3","gravatar_id":"","url":"https://api.github.com/users/shiftkey","html_url":"https://github.com/shiftkey","followers_url":"https://api.github.com/users/shiftkey/followers","following_url":"https://api.github.com/users/shiftkey/following{/other_user}","gists_url":"https://api.github.com/users/shiftkey/gists{/gist_id}","starred_url":"https://api.github.com/users/shiftkey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shiftkey/subscriptions","organizations_url":"https://api.github.com/users/shiftkey/orgs","repos_url":"https://api.github.com/users/shiftkey/repos","events_url":"https://api.github.com/users/shiftkey/events{/privacy}","received_events_url":"https://api.github.com/users/shiftkey/received_events","type":"User","site_admin":true},"body":"To make this crystal-clear, perhaps something like\r\n\r\n> `IsExecuting` observable will not report on your asynchronous method when it is inside the `Subscribe`","created_at":"2015-02-02T21:02:03Z","updated_at":"2015-02-02T21:02:03Z","html_url":"https://github.com/reactiveui/rxui-design-guidelines/pull/14#discussion_r23958176","pull_request_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/pulls/14","_links":{"self":{"href":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/pulls/comments/23958176"},"html":{"href":"https://github.com/reactiveui/rxui-design-guidelines/pull/14#discussion_r23958176"},"pull_request":{"href":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/pulls/14"}}},"pull_request":{"url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/pulls/14","id":28479213,"html_url":"https://github.com/reactiveui/rxui-design-guidelines/pull/14","diff_url":"https://github.com/reactiveui/rxui-design-guidelines/pull/14.diff","patch_url":"https://github.com/reactiveui/rxui-design-guidelines/pull/14.patch","issue_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/issues/14","number":14,"state":"open","locked":false,"title":"Added async command best practices","user":{"login":"kmcginnes","id":212862,"avatar_url":"https://avatars.githubusercontent.com/u/212862?v=3","gravatar_id":"","url":"https://api.github.com/users/kmcginnes","html_url":"https://github.com/kmcginnes","followers_url":"https://api.github.com/users/kmcginnes/followers","following_url":"https://api.github.com/users/kmcginnes/following{/other_user}","gists_url":"https://api.github.com/users/kmcginnes/gists{/gist_id}","starred_url":"https://api.github.com/users/kmcginnes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kmcginnes/subscriptions","organizations_url":"https://api.github.com/users/kmcginnes/orgs","repos_url":"https://api.github.com/users/kmcginnes/repos","events_url":"https://api.github.com/users/kmcginnes/events{/privacy}","received_events_url":"https://api.github.com/users/kmcginnes/received_events","type":"User","site_admin":false},"body":"The difference between the typical `ReactiveCommand.Create()` and the async version `ReactiveCommand.CreateAsyncObservable()`, or its brethren, can be confusing to new users. I wanted to spell out the differences.","created_at":"2015-02-02T16:04:17Z","updated_at":"2015-02-02T21:02:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a9f45e9c31f156d469901a5a203b03dbf4e639bd","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/pulls/14/commits","review_comments_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/pulls/14/comments","review_comment_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/pulls/comments/{number}","comments_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/issues/14/comments","statuses_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/statuses/c44d5b00084964ad661dcfee91438d29218e8ee7","head":{"label":"kmcginnes:master","ref":"master","sha":"c44d5b00084964ad661dcfee91438d29218e8ee7","user":{"login":"kmcginnes","id":212862,"avatar_url":"https://avatars.githubusercontent.com/u/212862?v=3","gravatar_id":"","url":"https://api.github.com/users/kmcginnes","html_url":"https://github.com/kmcginnes","followers_url":"https://api.github.com/users/kmcginnes/followers","following_url":"https://api.github.com/users/kmcginnes/following{/other_user}","gists_url":"https://api.github.com/users/kmcginnes/gists{/gist_id}","starred_url":"https://api.github.com/users/kmcginnes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kmcginnes/subscriptions","organizations_url":"https://api.github.com/users/kmcginnes/orgs","repos_url":"https://api.github.com/users/kmcginnes/repos","events_url":"https://api.github.com/users/kmcginnes/events{/privacy}","received_events_url":"https://api.github.com/users/kmcginnes/received_events","type":"User","site_admin":false},"repo":{"id":30152607,"name":"rxui-design-guidelines","full_name":"kmcginnes/rxui-design-guidelines","owner":{"login":"kmcginnes","id":212862,"avatar_url":"https://avatars.githubusercontent.com/u/212862?v=3","gravatar_id":"","url":"https://api.github.com/users/kmcginnes","html_url":"https://github.com/kmcginnes","followers_url":"https://api.github.com/users/kmcginnes/followers","following_url":"https://api.github.com/users/kmcginnes/following{/other_user}","gists_url":"https://api.github.com/users/kmcginnes/gists{/gist_id}","starred_url":"https://api.github.com/users/kmcginnes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kmcginnes/subscriptions","organizations_url":"https://api.github.com/users/kmcginnes/orgs","repos_url":"https://api.github.com/users/kmcginnes/repos","events_url":"https://api.github.com/users/kmcginnes/events{/privacy}","received_events_url":"https://api.github.com/users/kmcginnes/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kmcginnes/rxui-design-guidelines","description":"A set of practices to help maintain sanity when building an RxUI client application distilled from hard lessons learned.","fork":true,"url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines","forks_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/forks","keys_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/teams","hooks_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/hooks","issue_events_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/issues/events{/number}","events_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/events","assignees_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/assignees{/user}","branches_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/branches{/branch}","tags_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/tags","blobs_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/git/refs{/sha}","trees_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/statuses/{sha}","languages_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/languages","stargazers_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/stargazers","contributors_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/contributors","subscribers_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/subscribers","subscription_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/subscription","commits_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/commits{/sha}","git_commits_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/git/commits{/sha}","comments_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/comments{/number}","issue_comment_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/issues/comments/{number}","contents_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/contents/{+path}","compare_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/merges","archive_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/downloads","issues_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/issues{/number}","pulls_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/pulls{/number}","milestones_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/milestones{/number}","notifications_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/labels{/name}","releases_url":"https://api.github.com/repos/kmcginnes/rxui-design-guidelines/releases{/id}","created_at":"2015-02-01T17:00:28Z","updated_at":"2015-01-30T15:00:05Z","pushed_at":"2015-02-02T20:33:19Z","git_url":"git://github.com/kmcginnes/rxui-design-guidelines.git","ssh_url":"git@github.com:kmcginnes/rxui-design-guidelines.git","clone_url":"https://github.com/kmcginnes/rxui-design-guidelines.git","svn_url":"https://github.com/kmcginnes/rxui-design-guidelines","homepage":null,"size":224,"stargazers_count":0,"watchers_count":0,"language":null,"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":"reactiveui:master","ref":"master","sha":"7f570db29cfe264ef1fe81f009de3cd79ceec9f9","user":{"login":"reactiveui","id":2327577,"avatar_url":"https://avatars.githubusercontent.com/u/2327577?v=3","gravatar_id":"","url":"https://api.github.com/users/reactiveui","html_url":"https://github.com/reactiveui","followers_url":"https://api.github.com/users/reactiveui/followers","following_url":"https://api.github.com/users/reactiveui/following{/other_user}","gists_url":"https://api.github.com/users/reactiveui/gists{/gist_id}","starred_url":"https://api.github.com/users/reactiveui/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reactiveui/subscriptions","organizations_url":"https://api.github.com/users/reactiveui/orgs","repos_url":"https://api.github.com/users/reactiveui/repos","events_url":"https://api.github.com/users/reactiveui/events{/privacy}","received_events_url":"https://api.github.com/users/reactiveui/received_events","type":"Organization","site_admin":false},"repo":{"id":22623657,"name":"rxui-design-guidelines","full_name":"reactiveui/rxui-design-guidelines","owner":{"login":"reactiveui","id":2327577,"avatar_url":"https://avatars.githubusercontent.com/u/2327577?v=3","gravatar_id":"","url":"https://api.github.com/users/reactiveui","html_url":"https://github.com/reactiveui","followers_url":"https://api.github.com/users/reactiveui/followers","following_url":"https://api.github.com/users/reactiveui/following{/other_user}","gists_url":"https://api.github.com/users/reactiveui/gists{/gist_id}","starred_url":"https://api.github.com/users/reactiveui/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reactiveui/subscriptions","organizations_url":"https://api.github.com/users/reactiveui/orgs","repos_url":"https://api.github.com/users/reactiveui/repos","events_url":"https://api.github.com/users/reactiveui/events{/privacy}","received_events_url":"https://api.github.com/users/reactiveui/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/reactiveui/rxui-design-guidelines","description":"A set of practices to help maintain sanity when building an RxUI client application distilled from hard lessons learned.","fork":false,"url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines","forks_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/forks","keys_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/keys{/key_id}","collaborators_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/teams","hooks_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/hooks","issue_events_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/issues/events{/number}","events_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/events","assignees_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/assignees{/user}","branches_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/branches{/branch}","tags_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/tags","blobs_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/git/refs{/sha}","trees_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/git/trees{/sha}","statuses_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/statuses/{sha}","languages_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/languages","stargazers_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/stargazers","contributors_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/contributors","subscribers_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/subscribers","subscription_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/subscription","commits_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/commits{/sha}","git_commits_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/git/commits{/sha}","comments_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/comments{/number}","issue_comment_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/issues/comments/{number}","contents_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/contents/{+path}","compare_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/compare/{base}...{head}","merges_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/merges","archive_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/downloads","issues_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/issues{/number}","pulls_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/pulls{/number}","milestones_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/milestones{/number}","notifications_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/labels{/name}","releases_url":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/releases{/id}","created_at":"2014-08-04T23:44:35Z","updated_at":"2015-01-30T15:00:05Z","pushed_at":"2015-01-27T22:30:34Z","git_url":"git://github.com/reactiveui/rxui-design-guidelines.git","ssh_url":"git@github.com:reactiveui/rxui-design-guidelines.git","clone_url":"https://github.com/reactiveui/rxui-design-guidelines.git","svn_url":"https://github.com/reactiveui/rxui-design-guidelines","homepage":null,"size":224,"stargazers_count":119,"watchers_count":119,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":6,"forks":9,"open_issues":6,"watchers":119,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/pulls/14"},"html":{"href":"https://github.com/reactiveui/rxui-design-guidelines/pull/14"},"issue":{"href":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/issues/14"},"comments":{"href":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/issues/14/comments"},"review_comments":{"href":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/pulls/14/comments"},"review_comment":{"href":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/pulls/14/commits"},"statuses":{"href":"https://api.github.com/repos/reactiveui/rxui-design-guidelines/statuses/c44d5b00084964ad661dcfee91438d29218e8ee7"}}}}