Bindable LINQ

Reactive Programming for the .NET Framework

Reactive Programming

Reactive Programming is programming paradigm with a focus on automatic reactions to changes in data. While other programming paradigms, such as object oriented or functional programming, focus on discreet evaluation of code, the reactive programming paradigm instead focuses on continuous evaluation, and propagation of change.

To understand the difference between discreet and continuous evaluation, consider the following familiar C# code:

decimal total = 0;
IList<LineItem> lineItems = ...;
foreach (var item in lineItems) 
{
    total += item.Quantity * item.Price;
}

The value of the total is derived from the lineItems collection. But in this case, once the foreach loop has completed and the total variable assigned, this relationship is lost. If the lineItems collection, from which the total was derived from, changes, the total will not change. You can think think of this code as representing a "point-in-time" snapshot of the total.

In a reactive programming language, the relationship between the source - lineItems - and the destination - total - should be maintained at all times, and changes to the source should be propagated.

Bindable LINQ allows you to use the familiar syntax of LINQ queries in a reactive programming way. For example, the order totaling code above could be written in Bindable LINQ as:

ObservableCollection<LineItem> lineItems = ...;
IBindable<decimal> total = lineItems.AsBindable().Sum(li => li.Quantity * li.Price);

Further reading: