I'm trying to understand a few things about RxJs. What I would like to do is consume some JSON data and immediately begin to render that data on the DOM as it's coming in. I've setup the stream request, response, and display. It's outputting every just fine but it's doing it all at once and not over time.
I want to start showing the data on the page as its coming in, instead of waiting for the whole file to complete then show at once which would create a long wait time.
//Cache the selector
var $resultList = $('.results');
//Gets the JSON (this will not be a static file,just for testing)
var requestStream = Rx.Observable.just("/results.json");
var responseStream = requestStream
.flatMap(function(requestUrl) {
return Rx.Observable.fromPromise(jQuery.getJSON(requestUrl))
});
var displayStream = responseStream.subscribe(
function(response) {
//This maps to a Handlebars Template and puts it on the DOM
$resultList.html(compiledTemplate(response));
},
function(err) {
console.log('Error: %s', err);
},
function() {
console.log('Completed');
});
//Sample of the data from the JSON file
Object{
beginIndex: "1"
catId: "111"
endIndex: "1"
products: Array[100]
}