UNPKG

@apollo-elements/fast

Version:

👩‍🚀🌛 FastElements for Apollo GraphQL 🚀👨‍🚀

55 lines (44 loc) 1.54 kB
import { __decorate } from "tslib"; import { ApolloSubscriptionController } from '@apollo-elements/core/apollo-subscription-controller'; import { Observable, observable } from '@microsoft/fast-element'; import { FASTControllerHost } from './fast-controller-host'; /** * `ApolloSubscriptionBehavior` * * 🚀 FAST Behavior that connects to your Apollo cache. */ export class ApolloSubscriptionBehavior extends ApolloSubscriptionController { constructor(hostElement, subscription, options) { super(new FASTControllerHost(hostElement), subscription, { ...options, hostElement }); /** * Latest query data. */ this.data = null; this.loading = false; this.error = null; this.errors = []; this.variables = options?.variables ?? null; hostElement.$fastController.addBehaviors([this]); } get variables() { Observable.track(this, 'variables'); return super.variables; } set variables(value) { super.variables = value; Observable.notify(this, 'variables'); } bind(_source, _context) { this.hostConnected(); } unbind(_source) { this.hostDisconnected(); } } __decorate([observable], ApolloSubscriptionBehavior.prototype, "data", void 0); __decorate([observable], ApolloSubscriptionBehavior.prototype, "loading", void 0); __decorate([observable], ApolloSubscriptionBehavior.prototype, "error", void 0); __decorate([observable], ApolloSubscriptionBehavior.prototype, "errors", void 0); //# sourceMappingURL=apollo-subscription-behavior.js.map