O'Reilly logo

Programming Reactive Extensions and LINQ by Paul Betts, Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using jQuery AJAX with RxJS

One use case that is particularly compelling for RxJS is its integration with jQuery's AJAX library. Dealing with multiple callbacks in JavaScript can be a particularly daunting affair, especially because in JavaScript it is much harder to track down errors due to the dynamic nature of the language. Fortunately, using RxJS to make AJAX calls is quite straightforward. Let's look at the following example, a function to search through the Open Source projects hosted on GitHub:

var searchGitHub = function(term) {   var params = {     url: "http://github.com/api/v2/json/repos/search/" + encodeURI(term),     data: 'json'   };   return $.ajaxAsObservable(params)     .Select(function(x) { return x.data.repositories });

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required