Reactive Extensions for JavaScript


We’re proud to announce the availability of Reactive Extensions for Javascript. This port brings the power of Reactive programming to JavaScript. It allows you to use the Rx combinators in JavaScript and it does this in a download size of less than 7Kb (GZipped). RxJS provides easy to use conversions from existing DOM, XmlHttpRequest and jQuery events to Rx push-collections, allowing users to seamlessly plug Rx into their existing JavaScript-based web sites.

To give RxJs a try, download the installer. The installer comes with documentation and a small animation-based sample. You can provide feedback on RxJS on the regular Rx forum, and of course help the Rx community to convert the 101 Rx samples to JavaScript!

For an introduction, watch the C9 Introduction to Reactive Extensions for JavaScript video:

Get Microsoft Silverlight


Comments (8)

  1. nghianguyen says:

    Here is a simple testing page

    <html>

    <head><title>Rx Examples</title>

    <script language="javascript" type="text/javascript" src="Rx.js"></script>

    <script language="javascript" type="text/javascript">

    function window_onload()

    {

       var mouseclick = Rx.Observable.FromDOMEvent(document.getElementById("divTest"), "click");

       mouseclick.Subscribe(function(e) {alert(e.target.id + " is clicked");});

    }

    </script>

    </head>

    <body onload="window_onload()">

    <div id="divTest">Click me</div>

    </body>

    </html>

    It is working with FireFox 3.6.3, but not working with IE8 on Windows 7

    Here is the error message i got with IE.

    ——————————————————————————

    Webpage error details

    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MS-RTC LM 8)

    Timestamp: Tue, 13 Apr 2010 02:22:03 UTC

    Message: Object doesn’t support this property or method

    Line: 6

    Char: 18996

    Code: 0

    URI: http://localhost/RxExample/Rx.js

    ——————————————————————————

    I tried with FromJQueryEvent() method and it works fine with both browsers. I seems the error is coming from the FromDOMEvent() method.

    Any ideas?

  2. JeffVa says:

    Use FromHtmlEvent, that method will call FromIEEvent on IE and FromDOMEvent on other browsers.

  3. nghianguyen says:

    Using FromHtmlEvent is working now. Thanks so much, JeffVa.

  4. khalid99h says:

    hi,

    looks good.

    Can you put any async Rx example.

    Thanks,

  5. austegard says:

    If interested in the JS Rx implementation, then Matthew Podwysocki’s series of posts is a MUST READ: http://weblogs.asp.net/podwysocki/archive/tags/Reactive+Framework/default.aspx

    Here are a few of his posts:

    Creating Observables

    Creating Observers

    jQuery Integration

    Composing Callbacks

    From Blocking to Async

    Wikipedia Lookup

    Composing Deeper

    Bing Maps and Twitter Mashup

    Drag and Drop

    jQuery Live Event integration

    jQuery AJAX integration

    A Separation of Concerns

    Aggregates – Part 1 and Part 2

    Join Operators

    Going “Parallel” with ForkJoin

  6. ambrose adamson says:

    will there anything for unmanaged environment such as C++, etc.

  7. Some Issues says:

    Hello, RxJs is great, the documentation about it is a bit confusing to me. Several pages like this one say, "To give RxJs a try, download the installer." The link does not lead to an installer but a rar file. The other thing is that Rx.Observable.XmlHttpRequest does not work on my side. Is there any sample using this function? the sample in the blog comes without source code, and writing the source code from the sample does not work on my side, because this function is missing.

    Thx for any clarification.

    t

  8. issues resolved says:

    adding rx.html.js did it. would be great to see this in the docu. "Assembly:  RxJS (in RxJS.dll)" is quite misleading 🙂