Rx: Materialize() – Stream Notifcations

Jeffery’s posting offer some insight in to what you can do with Materialize(). Using the Materialize() I can inspect the stream and handle any error without having to pass an Action though the various layer within an application:


public static IObservable CheckForErrorInStream(this IObservable source, Action action)
{
   return source.Materialize().Select(n =>
      {
         if (n.Kind == NotificationKind.OnError)
         {
            var error = (Notification.OnError) n;
            action(error.Exception);
          }
       return n;
   }).Dematerialize();
}

Advertisement

~ by mdavey on January 29, 2010.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

Join 273 other followers