{"id":1277,"date":"2014-02-05T20:38:22","date_gmt":"2014-02-05T20:38:22","guid":{"rendered":"http:\/\/putridparrot.com\/blog\/?p=1277"},"modified":"2014-02-05T20:38:22","modified_gmt":"2014-02-05T20:38:22","slug":"reactiveui-5-x-changes","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/reactiveui-5-x-changes\/","title":{"rendered":"ReactiveUI 5.x changes"},"content":{"rendered":"<p>I&#8217;m not sure when these changes were made, but I just updated an application to use both .NET 4.5 and the latest NuGet packages for ReactiveUI (version 5.4) and looks like quite a few things have changed.<\/p>\n<p>This post is just going to show some of the changes I&#8217;ve hit whilst migrating my code. This is probably not a full list as I haven&#8217;t used all the parts of ReactiveUI in my applications thus far. <\/p>\n<p><strong>RaiseAndSetIfChanged<\/strong><\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/ old style\r\nthis.RaiseAndSetIfChanged(x =&gt; x.IsSelected, ref isSelected, value);\r\n\r\n\/\/ new style\r\nthis.RaiseAndSetIfChanged(ref isSelected, value);\r\n<\/pre>\n<p>See the post on <a href=\"http:\/\/putridparrot.com\/blog\/callermembernameattribute\/\" title=\"CallerMemberNameAttribute\" target=\"_blank\">CallerMemberNameAttribute<\/a> for more information on how this works. With this we no longer need to write the lambda expressions required by earlier versions.<\/p>\n<p>Note: For raising events on properties other than the current property, i.e. if IsSelected is a property above and IsUpdated should also raise a property change event we use<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nthis.RaiseAndSetIfChanged(&quot;IsUpdated&quot;);\r\n<\/pre>\n<p><strong><br \/>\nRxApp.DeferredScheduler<\/strong><\/p>\n<p>It would appear that the <em>RxApp.DeferredScheduler<\/em> has been renamed as <em>RxApp.MainThreaScheduler<\/em>. Admittedly a better name.<\/p>\n<p><strong>RxApp.MessageBus<\/strong><\/p>\n<p>Looks like we just use the <em>MessageBux.Current<\/em> instead.<\/p>\n<p><strong>ReactiveAsyncCommand<\/strong><\/p>\n<p>It appears that <em>ReactiveAsyncCommand<\/em> has merged into <em>ReactiveCommand<\/em>, so changes look like this<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/ old stype\r\nClearSearch = new ReactiveAsyncCommand(null);\r\nClearSearch.RegisterAsyncAction(o =&gt;\r\n{\r\n   \/\/ do something\r\n});\r\n\r\n\/\/ new style\r\nClearSearch = new ReactiveCommand();\r\nClearSearch.RegisterAsyncAction(o =&gt;\r\n{\r\n   \/\/ do something\r\n});\r\n<\/pre>\n<p>but there&#8217;s more<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/ old style\r\nOK = ReactiveCommand.Create(_ =&gt; true, DoOK);\r\n\r\n\/\/ new style\r\nOK = new ReactiveCommand();\r\nOK.Subscribe(DoOK);\r\n<\/pre>\n<p>If we need to enable\/disable commands then we can pass an IObservable into the first parameter of ReactiveCommand, for example<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nOK = new ReactiveCommand(this.WhenAny(x =&gt; x.Text, x =&gt; !String.IsNullOrEmpty(x.Value)));\r\n<\/pre>\n<p><strong><br \/>\nIReactiveAsyncCommand<\/strong><\/p>\n<p>As above, <em>IReactiveAsyncCommand<\/em> has been merged into <em>IReactiveCommand<\/em>.<\/p>\n<p><strong>ReactiveCollection<\/strong><\/p>\n<p>This has been renamed to <em>ReactiveList<\/em>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m not sure when these changes were made, but I just updated an application to use both .NET 4.5 and the latest NuGet packages for ReactiveUI (version 5.4) and looks like quite a few things have changed. This post is just going to show some of the changes I&#8217;ve hit whilst migrating my code. This [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1277","post","type-post","status-publish","format-standard","hentry","category-c"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/1277","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=1277"}],"version-history":[{"count":6,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/1277\/revisions"}],"predecessor-version":[{"id":1288,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/1277\/revisions\/1288"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=1277"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=1277"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=1277"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}