Thursday, 11 May 2017

How to create an RxJs Observable from a node request

Currently can create an observable explicitly as follows:

const Rx = require("rxjs");
const request = require("request");

        return Rx.Observable.create(function (observer) {
            request(options, function (error, response, body) {
                if (error) {
                    observer.error(error);
                } else {
                    observer.next(response);
                    observer.complete();
                }
            });
        });

Is there a way to do this with the RxJs library?



via Solubris

No comments:

Post a Comment