Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

falcor-http-ws-datasource

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

falcor-http-ws-datasource - npm Package Compare versions

Comparing version 0.1.7 to 0.1.8

96

dist/falcor-http-ws-datasource.js

@@ -33,2 +33,6 @@ 'use strict';

var _q = require('q');
var _q2 = _interopRequireDefault(_q);
var noop = function noop() {};

@@ -139,17 +143,89 @@

}, {
key: '_monitorRequest',
value: function _monitorRequest(res) {
key: '_retry',
value: function _retry(method, args, observer) {
var _this2 = this;
var res = undefined;
if (method === 'get') {
res = _get(Object.getPrototypeOf(FalcorHttpPullWebSocketPushDataSource.prototype), 'get', this).apply(this, args);
} else if (method === 'set') {
res = _get(Object.getPrototypeOf(FalcorHttpPullWebSocketPushDataSource.prototype), 'set', this).apply(this, args);
} else if (method === 'call') {
res = _get(Object.getPrototypeOf(FalcorHttpPullWebSocketPushDataSource.prototype), 'call', this).apply(this, args);
}
res.subscribe(function (res) {
// Recall the onError callback for logging purposes only
_this2._needRetryOnErrors(method, args, res);
observer.onNext(res);
}, function (err) {
observer.onError(err);
}, function () {
_this2._finishedRequest();
observer.onCompleted();
});
}
}, {
key: '_needRetryOnErrors',
value: function _needRetryOnErrors(method, args, node) {
var $type = node ? node.$type : null;
if ($type === 'error') {
return this.onError(method, args, node.value);
} else if (node && typeof node === 'object') {
var needRetries = [];
for (var key in node) {
needRetries.push(this._needRetryOnErrors(method, args, node[key]));
}
return _q2['default'].all(needRetries).then(function (retries) {
return retries.reduce(function (r, needRetry) {
return r || needRetry;
});
});
}
return _q2['default'].fcall(function () {
return false;
});
}
}, {
key: '_monitorRequest',
value: function _monitorRequest(method, args, res) {
var _this3 = this;
this._fireRequest();
var observable = Observable.create(function (observer) {
var validateNeedRetry = _q2['default'].defer();
res.subscribe(function (res) {
return observer.onNext(res);
_this3._needRetryOnErrors(method, args, res).then(function (needRetry) {
if (needRetry) {
_this3._retry(method, args, observer);
} else {
observer.onNext(res);
}
validateNeedRetry.resolve(needRetry);
});
}, function (err) {
_this2.onError(err);
observer.onError(err);
_this3.onError(method, args, err).then(function (needRetry) {
if (needRetry) {
_this3._retry(method, args, observer);
} else {
observer.onError(err);
}
validateNeedRetry.resolve(needRetry);
});
}, function () {
_this2._finishedRequest();
observer.onCompleted();
validateNeedRetry.promise.then(function (needRetry) {
if (!needRetry) {
_this3._finishedRequest();
observer.onCompleted();
}
});
});

@@ -170,3 +246,3 @@

// returns an Observable if you wanted to map/filter/reduce/etc
return this._monitorRequest(_get(Object.getPrototypeOf(FalcorHttpPullWebSocketPushDataSource.prototype), 'get', this).apply(this, args));
return this._monitorRequest('get', args, _get(Object.getPrototypeOf(FalcorHttpPullWebSocketPushDataSource.prototype), 'get', this).apply(this, args));
}

@@ -181,3 +257,3 @@ }, {

// returns an Observable if you wanted to map/filter/reduce/etc
return this._monitorRequest(_get(Object.getPrototypeOf(FalcorHttpPullWebSocketPushDataSource.prototype), 'set', this).apply(this, args));
return this._monitorRequest('set', args, _get(Object.getPrototypeOf(FalcorHttpPullWebSocketPushDataSource.prototype), 'set', this).apply(this, args));
}

@@ -192,3 +268,3 @@ }, {

// returns an Observable if you wanted to map/filter/reduce/etc
return this._monitorRequest(_get(Object.getPrototypeOf(FalcorHttpPullWebSocketPushDataSource.prototype), 'call', this).apply(this, args));
return this._monitorRequest('call', args, _get(Object.getPrototypeOf(FalcorHttpPullWebSocketPushDataSource.prototype), 'call', this).apply(this, args));
}

@@ -195,0 +271,0 @@ }, {

5

package.json
{
"name": "falcor-http-ws-datasource",
"version": "0.1.7",
"version": "0.1.8",
"description": "Falcor HTTP and WebSocket datasource",

@@ -21,3 +21,4 @@ "homepage": "",

"socket.io-client": "^1.4.8",
"uuid": "^2.0.1"
"uuid": "^2.0.1",
"q": "^1.4.1"
},

@@ -24,0 +25,0 @@ "devDependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc