Select Many: Reactive Extensions’ Mother Of All Operators [Chaining]

Reactive Programming, Posting # 9

Reactive Extensions (Rx) has a number of operators that we’ve looked at already, DoubleTranslationincluding Select, Throttle, Subscribe and so forth.  While SelectMany is not the most important Rx operator, it is surely the most powerful.

SelectMany’s principal job is to allow you to select against an IObservable<T>, run a func<u> and get back an IObservable<u>

IObservable<U> SelectMany(IObservable<T>, func<U>)

Read that in your head “SelectMany takes an IObservable of T and a func (funk) of U and returns an IObservable of U.”

Today we’ll take a look at the case of having a  function that returns an IObservable and you wish to then pass the results to a function that returns an IObservable. That is, the case where you wan to chain calls.   If you were to use Select, you would end up with an IObservable<IObservable<T>> which is not what you want. SelectMany flattens that for you.

Continue reading

Posted in Patterns & Skills, Reactive, WindowsPhone | Tagged | 5 Comments

Sterling DB on top of Isolated Storage – 2

Windows Phone From Scratch #39

 

In yesterday’s posting we looked at the Sterling Database. and how to set up and initialize tables, store an retrieve data.  Today we’ll build on that to set up the database in App.xaml so that we can handle tombstoning.

Continue reading

Posted in Patterns & Skills | Tagged , , | 2 Comments

When Isolated Storage Isn’t Enough

Windows Phone From Scratch #38

When you wish to persist state across usages of your application, Isolated Storage allows you to write to the disk and stash away key-value pairs.  For state, this is usually sufficient, but if what you wish to persist is data, especially relational data, then Isolated Storage is a bit limiting.

To meet this need for a more robust data storage scheme, a number of libraries have been developed that work on top of isolated storage.  This posting is the first in a series that will examine these options; beginning with the Sterling Database.

Continue reading

Posted in Patterns & Skills | Tagged , , , , | 5 Comments

Asynchronous Callbacks with Rx

Reactive Programming, Posting # 8

One of the tried and true patterns in .NET programming is to call an Asynchronous service (e.g., BeginGetResponse) and to then provide a callback to a second method for when the call completes.  This can get very complex very quickly if you have chained calls (call this, then when you finish, call that)

Let’s take a look at how you can simplify such a call with Rx by examining making a HTTPWebRequest.

Continue reading

Posted in Data, Essentials, Reactive | Tagged | 11 Comments

Silverlight Sans Xaml?

Are we far enough along in the development of WYSIWYG tools, specifically both the NoXaml design surface in Visual Studio, and even more so, Expression Blend, that the right way to teach Silverlight and Windows Phone programming is without Xaml?

I hear your screams of protest already:

“That’s fine for some things but not for… “ 

What?  What can’t you do in the UI designer?

“But… when you get in trouble you’ll need Xaml…”

This argument rings of the old standby “you can’t really program in foo unless you understand Assembler. When was the last time you needed assembler? Those days are over. Are the days of coding with underlying Xaml over?

Certainly at some point tools like Blend will create better Xaml than will be created by hand-coding, and with fewer errors.  Are we there yet?

Obviously you want to go to Visual Studio for code, but that is not an alternative to Xaml. All I’m suggesting here is that new books and new tutorials on Silverlight or Windows Phone do not need to teach Xaml – that everything you can do in Xaml you can do as well or better in Blend (or using the Visual Studio design surface).

Posted in Community, Essentials, Opinion, WindowsPhone | Tagged | 36 Comments

Yet Another Podcast #25–Glenn Block / WCF

Talking with the esteemed Mr. Glenn Block about WCF, HTTP and ever so much more.

Glenn is the Program Manager for the WCF Web APIs, former PM for MEF and generally brilliant.

Listen | Return to Yet Another Podcast

Call in comments:  1-347-YAP-CAST

rssiTunesalt

Posted in Patterns & Skills | Tagged | 8 Comments

Reactive Drag and Drop Part 2

Reactive Programming, Posting # 7

In Part 1 of this 2 part posting we looked at capturing the mouse movements.  The key code in Part 1 was,

var q = from start in mousedown
        from pos in mousemove.StartWith( start )
        .TakeUntil( mouseup )
        select pos;

Now, in part 2, rather than just getting the coordinates of the mouse, we want to find the delta so that we can move the image with the changes in the mouse position. 

Continue reading

Posted in Linq, Mini-Tutorial, Reactive, WindowsPhone | Tagged , , | 2 Comments

Lambda–Not as weird as it sounds

Windows Phone From Scratch #36

Yesterday I wrote a few posts on LINQ but carefully avoided using Lambda expressions. Now it is time to look at this feature that sounds fierce but is really fairly straight-forward.

Lambda expressions are just a short-hand notation for declaring delegates.

Continue reading

Posted in Patterns & Skills | 7 Comments

Linq to XML

A LINQ Tutorial

Earlier, we took a look at two variants on Linq statements, one against a collection of integers, and then another against a collection of user-defined objects (Customers).

Now, we’ll read an XML file and select from that with Linq.

Continue reading

Posted in Linq, Mini-Tutorial | Tagged | 8 Comments

Linq with Objects

A LINQ Tutorial

 

In my earlier post, we took a first look at a Linq query against a collection of integers. In this posting, we’ll look at creating a Linq query against a collection of objects.

Continue reading

Posted in Linq, Mini-Tutorial | Tagged | 2 Comments

Getting Started With Linq

A LINQ Tutorial

If you are serious about Windows Phone programming then it is imperative to become at least familiar with LINQ.  This is given additional impetus by the emerging importance of Reactive Programming, a full understanding of which requires at least a working understanding of LINQ.

Over the next few weeks or more, I’ll explore LINQ in a series of episodic postings.  None of this is terribly difficult, though there are some syntactic bits that take a little getting used to.

Continue reading

Posted in Linq, Patterns & Skills | Tagged | 1 Comment

Video: Reactive Phone Programming For Windows Phone 7

Reactive Programming: Posting #6

I just posted a new video on Reactive Programming for Windows Phone 7, here. This is timed nicely to go with the more in-depth podcast on Reactive Programming, available here.

Posted in Reactive | Tagged | 3 Comments