SassAndCoffee 1.1 issues with AppHarbor
SassAndCoffee 1.1 currently doesn’t work on AppHarbor, and returns a 502 Gateway Error on the site. I’m working with the AppHarbor folks to fix this as soon as I can. Sorry about this!
The Details
On startup, we write out the V8 DLL to a temporary directory and call Assembly.Load to load it. Unfortunately, even though the write succeeds, the Load fails for some reason. On AppHarbor, we would always fall back to Jurassic, but in 1.1 I disabled this fallback because of performance issues (and because it made it harder to debug the V8 load failures).
ReactiveUI posts now in PDF format
Since my blog software is rather lacking as an official document source for ReactiveUI, I’ve put together the blog posts in chronological order, cleaned them up, and compiled them into a single PDF, called “The Zen of ReactiveUI”. I’ve also created a version in ePub format, so that you can put it onto an eBook reader. If you’re interested in either RxUI, or the Reactive Extensions in general, I think the PDF is a good read – it talks about not only how RxUI works, but a lot of interesting background behind how things work.
Get the document here:
New Release: ReactiveUI 2.1
What does ReactiveUI do?
ReactiveUI is a M-V-VM framework like MVVM Light or Caliburn.Micro, that is deeply integrated with the Reactive Extensions for .NET. This allows you to write code in your ViewModel that is far more elegant and terse when expressing complex stateful interactions, as well as much simpler handling of async operations. Check out this video for an overview:
ReactiveUI on Hanselminutes
Check out the recent Hanselminutes episode about the Reactive Extensions as well if you’ve got more time. Scott and I chat about some of the ideas in RxUI and how we can take the ideas in the Reactive Extensions and use RxUI to apply them to Silverlight and WPF apps.
What’s new in ReactiveUI 2.1 – bindings galore!
- ObservableForProperty now accepts full paths, similar to Xaml bindings – this makes it much easier to write complex expressions
- Combining properties correctly is much easier with a new Object.WhenAny() method that acts like a n-way CombineLatest optimized for binding use
- A new method called BindTo allows you to automatically update a read-write property using an Observable; this can be combined with WithAny() to easily create one-way bindings between ViewModel objects
- Improved CachedSelectMany that allows you to share a cache between different parts of the code
- Utility method ToCommand which invokes an ICommand based on an IObservable
- ReactiveUI now uses the latest Rx.NET release, and solves some NuGet issues that were present in the WP7 release
- Lots of bug fixes, especially to MessageBus and ReactiveAsyncCommand; a huge thanks to the folks on the Google Group for helping out with bug reports
Had trouble with NuGet lately? We fixed that.
Recently, ReactiveUI has been having some trouble on NuGet, with both the WP7 and Desktop packages. Hopefully all of these problems have been fixed, though you’ll have to update your existing code to be compatible with the latest Rx.NET – for me, this mainly affected the Publish() operator, but is relatively easy to fix.
Where can I find the library?
On NuGet! The best way to install ReactiveUI for a project is by installing the ReactiveUI package for WPF/Silverlight projects, or ReactiveUI-WP7 for Windows Phone 7 projects.
If NuGet isn’t your thing, you can also find the binaries on the Github page: ReactiveUI 2.1.0.1.zip.
Where can I see a sample?
A sample project for WPF 4.0 that includes everything you need to see how it works is on the Github page: ReactiveUI 2.1 Sample.zip. It includes a small sample app, the RxUI binaries, and some sample test cases.
Interview with XAMLCast about ReactiveXaml
Awhile back I did an interview with XAMLCast about the philosophy behind ReactiveXaml and basically what the library is about. If you’ve got the time between checking out all the great PDC10 videos, check this out as well:
ReactiveXaml Series: On combining notifications
I was excited today when I got my first Email post to the Google Group for RxXaml, and even better, it was a great question; what the poster was asking about really strikes to the core of why Rx and ReactiveXaml are compelling in my mind. In my experimentation, I’ve come across a number of useful patterns that I should’ve mentioned earlier – I showed you how to get the notifications, but not how to use them!
When I say ‘notification’, you have to read into this term very broadly and kind of stretch your brain a bit: as a reminder, here are some examples of what are notifications in Rx and RxXaml:
- A simple .NET event (i.e. via Observable.FromEvent)
- Whenever a property changes (via ReactiveObject)
- When an ICommand is invoked (ReactiveCommand)
- Any time any sort of asynchronous operation completes (via Observable.FromAsyncCommand, ReactiveAsyncCommand, or QueuedAsyncMRUCache)
- In response to an explicit notification (via a Subject)
Combining notifications in meaningful ways
One of the most powerful parts of the Reactive Extensions is its ability to combine single events compositionally – when I describe what Rx is to people, I often use the description, “Rx gives you the ability to take simple events and combine them together into something more specific and useful – I don’t really care when the ‘MouseUp’ and ‘KeyDown’ events happen, I want to know when the ‘User dropped a file on the top left corner’ happens – tell me about that.”
To this effect, there are several tricks that we can do. The first one is, that you must remember that ReactiveObject fires its IObservable when any property changes – this means, that it’s very easy to watch an entire object. Often, this is useful enough – when it isn’t, Wherehelps you out:
// Any change will print something
Toaster.Subscribe(x => Console.WriteLine("{0} changed!", x.PropertyName);
// This is an observable that only notifies when the Foo property changes
var FooChanged = Toaster.Where(x => x.PropertyName == "Foo");
Merge, CombineLatest, and Zip – the ‘And’ and ‘Or’ of Rx
So, to combine several IObservables, we have a few useful methods that stand out. The first is Observable.Merge: as its name implies, Merge takes several IObservables of the same type, and returns an IObservable that fires when any one of its inputs fires. Thinking in a boolean sense, Merge is kind of like Or. Having to be of the same type isn’t as onerous of a requirement:
IObservable[int] O2;
IObservable[string] O3;
// Tell me when *any* of these 3 send a notification
var result = Observable.Merge(
O1.Select(_ => true), O2.Select(_ => true), O3.Select(_ => true)
);
One of the difficulties of Merge that can sometimes bite you, is that it is stateless – when you get a notification about O1, you don’t have any knowledge about what items came in on O2 or O3. For two IObservables, we have a handy method called Observable.CombineLatest. This method will “remember” the last item that came in on both sides – when O1 changes, it will give you the new O1 and the latest value of O2. Furthermore, we can take the result and expose it as a change-notifying property via ObservableAsPropertyHelper.
// They’re the mutable variables of Rx
Subject[int] s1;
Subject[int] s2;
// Combine s1 with s2 and write its output to Console
s1.CombineLatest(s2, (a,b) => a * b).Subscribe(Console.WriteLine);
s1.OnNext(5); // Nothing happens, no value for s2
s2.OnNext(10); // 10 came in, combine the 10 with whatever s1 was (5)
>>> 50
s2.OnNext(20); // 20 came in, still use s1′s latest value
>>> 100
s1.OnNext(2); // s1 is 1, take s2′s latest value (20)
>>> 40
Finally, we have Observable.Zip. Like the other two, this function also combines observables, but this function like its IEnumerable counterpart, is only concerned about pairs of items. This means, it’s more like “And” than the other two (remember that it’s extremely unlikely that notifications will come in at the exact same time so an “Observable.And” wouldn’t make much sense). Zip will not yield elements until it has both of its “slots” filled for the next item.
Subject[int] s2;
s1.Zip(s2, (a,b) => a * b).Subscribe(Console.WriteLine);
s1.OnNext(2); // Nothing, no pair yet
s1.OnNext(5); // Still no pair
s2.OnNext(10); // We’ve got a pair (2,10), let’s send it down
>>> 20
s1.OnNext(10); // s2′s empty, no pair
s2.OnNext(1); // 5 * 1
>>> 5
s2.OnNext(10); // 10*10
>>> 100
s2.OnNext(100); // s1′s empty, no output
Combining Notifications for Visual State Manager
Here’s another clever trick that I really like – often, we need to change the visual state on a variety of different notifications of different types and are unrelated. Here’s how to do it:
IObservable[float] AThirdThing;
var state = Observable.Merge(
SomethingToWatch.Select(_ => "State1"),
SomethingElse.Select(_ => "State2"),
AThirdThing.Select(_ => "State3")
);
state.Subscribe(x =>
VisualStateManager.GoToState(this, x, true));
Observable.Merge can also be used along with Scan to keep a reference count, check out this example from ReactiveAsyncCommand where we use two observables and Select them to 1 and -1, then keep a running count via Scan.
Comments are disabled
I’m sick of dealing with comment spam.
Oops, I have a blog
I’ll post something soon, I promise. In the meantime, follow @xpaulbettsx on Twitter
This is how I should be creating
VONNEGUT
I said in Slapstick that she was the person I wrote for—that every successful creative person creates with an audience of one in mind. That’s the secret of artistic unity. Anybody can achieve it, if he or she will make something with only one person in mind. I didn’t realize that she was the person I wrote for until after she died.
Via The Paris Review
My original contribution to the Failboat meme
Psst a riddle
This might help you to process movies that are defined higher than the garden-variety ones, but only if you think in hexadecimainfully:

