apollo-client-rxjs
Version:
Adds RxJS to ApolloClient
85 lines • 3.45 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import { Observable } from 'rxjs/Observable';
import { $$observable } from 'rxjs/symbol/observable';
import { ObservableQueryRef } from './utils/ObservableQueryRef';
var RxObservableQuery = (function (_super) {
__extends(RxObservableQuery, _super);
function RxObservableQuery(apollo, subscribe) {
var _this = _super.call(this, null) || this;
_this.apollo = apollo;
if (subscribe) {
_this._subscribe = subscribe;
}
return _this;
}
RxObservableQuery.prototype.lift = function (operator) {
var observable = new RxObservableQuery(this.apollo);
observable.source = this;
observable.operator = operator;
return observable;
};
RxObservableQuery.prototype.refetch = function (variables) {
return this.getObservableQuery().refetch(variables);
};
RxObservableQuery.prototype.stopPolling = function () {
return this.getObservableQuery().stopPolling();
};
RxObservableQuery.prototype.startPolling = function (p) {
return this.getObservableQuery().startPolling(p);
};
RxObservableQuery.prototype.fetchMore = function (options) {
return this.getObservableQuery().fetchMore(options);
};
RxObservableQuery.prototype.updateQuery = function (mapFn) {
this.getObservableQuery().updateQuery(mapFn);
};
RxObservableQuery.prototype.subscribeToMore = function (options) {
return this.getObservableQuery().subscribeToMore(options);
};
RxObservableQuery.prototype.result = function () {
return this.getObservableQuery().result();
};
RxObservableQuery.prototype.currentResult = function () {
return this.getObservableQuery().currentResult();
};
Object.defineProperty(RxObservableQuery.prototype, "variables", {
get: function () {
return this.getObservableQuery().variables;
},
enumerable: true,
configurable: true
});
RxObservableQuery.prototype.setOptions = function (opts) {
return this.getObservableQuery().setOptions(opts);
};
RxObservableQuery.prototype.setVariables = function (variables, tryFetch) {
if (tryFetch === void 0) { tryFetch = false; }
return this.getObservableQuery().setVariables(variables, tryFetch);
};
RxObservableQuery.prototype._subscribe = function (subscriber) {
if (this.source) {
return this.source['_subscribe'](subscriber);
}
var obs = this.getObservableQuery();
return obs[$$observable]().subscribe(subscriber);
};
RxObservableQuery.prototype.getObservableQuery = function () {
if (this.apollo instanceof ObservableQueryRef) {
var ref = this.apollo;
return ref.getRef();
}
return this.apollo;
};
return RxObservableQuery;
}(Observable));
export { RxObservableQuery };
//# sourceMappingURL=RxObservableQuery.js.map