How to use the @graffy/common.getUnknown function in @graffy/common

To help you get started, we’ve selected a few @graffy/common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github usegraffy / graffy / src / cache / Cache.js View on Github external
async putValue(value) {
    /*
      Merge value into cache, and get the change tree
      extraChanges = await normalizeSubscriptions()
      If raw, merge extraChanges into change and call listeners with that;
      Othersiwe, call listeners with values from cache
    */

    if (typeof value === 'undefined') value = {};
    merge(this.data, value);
    // console.log(this.id, 'value', value);

    const gaps = getUnknown(this.data, this.sumQuery);
    let fillData;
    if (gaps) {
      // The change added a link to some data we don't have in the cache.
      // We need to fetch it and also resubscribe.
      // console.log(
      //   'Change caused gaps',
      //   value && value.visitorsByTime && value.visitorsByTime.__page__,
      //   this.data &&
      //     this.data.visitorsByTime &&
      //     this.data.visitorsByTime.__page__,
      // );
      // console.log('SumQuery', this.sumQuery);
      // console.log('Gaps', gaps);
      await this.resubscribe();
      try {
        fillData = await this.store.get(gaps, {
github usegraffy / graffy / src / cache / subscribe.js View on Github external
async pub(change) {
    if (this.earlyChange) {
      merge(this.earlyChanges, change);
      return;
    }
    const { query, options, data } = this;

    // Returns early if the change does not have any overlap with the query.
    // DO NOT getKnown the change to only those changes that overlap; when the
    // overlapping portion includes a deletion in a range, the change set
    // may contain additional items to make up.
    if (!getKnown(change, linkKnown(data, query))) return;

    merge(data, change);

    const nextQuery = getUnknown(data, query);

    if (nextQuery) {
      const linked = await options.resolve(nextQuery);
      merge(data, linked);
      if (!options.values) merge(change, linked);
    }
    this.data = getKnown(data, query);
    this.push(options.values ? graft(this.data, query) || {} : change);
  }
}
github usegraffy / graffy / src / core / Subscription.js View on Github external
async pub(change) {
    if (this.earlyChange) {
      merge(this.earlyChange, change);
      return;
    }
    const { query, options, data } = this;

    // Returns early if the change does not have any overlap with the query.
    // DO NOT getKnown the change to only those changes that overlap; when the
    // overlapping portion includes a deletion in a range, the change set
    // may contain additional items to make up.
    if (!getKnown(change, linkKnown(data, query))) return;

    merge(data, change);

    const nextQuery = getUnknown(data, query);

    if (nextQuery) {
      const linked = await options.resolve(nextQuery);
      merge(data, linked);
      if (!options.values) merge(change, linked);
    }
    this.data = getKnown(data, query);
    this.push(options.values ? graft(this.data, query) || {} : change);
  }
}
github usegraffy / graffy / src / cache / subscribe.js View on Github external
const pub = async change => {
    if (earlyChange) {
      merge(earlyChange, change);
      return;
    }

    // Returns early if the change does not have any overlap with the query.
    // DO NOT getKnown the change to only those changes that overlap; when the
    // overlapping portion includes a deletion in a range, the change set
    // may contain additional items to make up.
    if (!getKnown(change, linkKnown(data, query))) return;

    merge(data, change);

    const nextQuery = getUnknown(data, query);

    if (nextQuery) {
      const linked = await options.resolve(nextQuery);
      merge(data, linked);
      if (!options.values) merge(change, linked);
    }
    data = getKnown(data, query);
    push(options.values ? graft(data, query) || {} : change);
  };
github usegraffy / graffy / src / cache / watch.js View on Github external
pubs[id] = async change => {
      if (earlyChange) {
        merge(earlyChange, change);
        return;
      }

      // Returns early if the change does not have any overlap with the query.
      // DO NOT getKnown the change to only those changes that overlap; when the
      // overlapping portion includes a deletion in a range, the change set
      // may contain additional items to make up.
      if (!getKnown(change, linkKnown(data, query))) return;

      merge(data, change);

      const nextQuery = getUnknown(data, query);

      if (nextQuery) {
        const linked = await store.get(nextQuery, options);
        merge(data, linked);
        if (!options.values) merge(change, linked);
      }
      data = getKnown(data, query);
      push(options.values ? graft(data, query) || {} : change);
    };
github usegraffy / graffy / src / cache / Cache.js View on Github external
getUnknown(query) {
    return getUnknown(this.data, query);
  }