1.0.1 • Published 9 years ago

rx-sidekick v1.0.1

Weekly downloads
4
License
ISC
Repository
-
Last release
9 years ago

#rx-sidekick

Create Rx.Observable sequences of http calls

##Install

npm install rx-sidekick

##Usage

var Sidekick = require("rx-sidekick").Sidekick;
var sidekick = Sidekick(
  {
    url:"http://www.google.com"
  });

var sub = sidekick.subscribe(function(responseData){
    var body = responseData[1];
    var response = responseData[0];

    console.log("Success");
  }, function(err){

  }, function(){
    sub.dispose();
    throw new Error("Should not have completed");
  });

#Success
#Success
...

To shutdown the polling and dispose sidekick

var sidekick = Sidekick(
  {
    url:"http://www.google.com"
  });

sidekick.connection.dispose();

##API

###Sidekick(config, params=undefined, hotCold = "hot") -> Rx.Observable

###Config Object properties

Propertytypeoptionaldefaultdescription
urlStringnoundefinedurl to make the http request
methodStringyes"GET"http method
headersObjectyesundefinedhttp headers
bodyObjectyesundefinedbody to be sent as a form to the endpoint
intervalNumberyes9000 (ms)interval to do polling against the endpoint
retryCountNumberyes3number of times to retry the endpoint if the call fails
timeoutNumberyes3000 (ms)amount of time allowed per http request

###Params (todo)

###hotCold Values are either "hot" or "cold".
Will produce a "hot" Observable or a "cold" Observable.
Note "hot" Observables are already connected and polling by the time the value is returned