How to use the @glimmer/reference.update function in @glimmer/reference

To help you get started, we’ve selected a few @glimmer/reference 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 emberjs / ember.js / packages / @ember / -internals / metal / lib / alias.ts View on Github external
get(obj: object, keyName: string): any {
    let ret: any;

    let propertyTag = tagForProperty(obj, keyName) as UpdatableTag;

    // We don't use the tag since CPs are not automatic, we just want to avoid
    // anything tracking while we get the altKey
    untrack(() => {
      ret = get(obj, this.altKey);
    });

    let lastRevision = getLastRevisionFor(obj, keyName);

    if (!validate(propertyTag, lastRevision)) {
      update(propertyTag, combine(getChainTagsForKey(obj, this.altKey)));
      setLastRevisionFor(obj, keyName, value(propertyTag));
      finishLazyChains(obj, keyName, ret);
    }

    consume(propertyTag);

    return ret;
  }
github emberjs / ember.js / packages / @ember / -internals / metal / lib / tracked.ts View on Github external
let value;

      // If the field has never been initialized, we should initialize it
      if (hasInitializer && !values.has(this)) {
        value = initializer.call(this);

        values.set(this, value);
      } else {
        value = values.get(this);
      }

      // Add the tag of the returned value if it is an array, since arrays
      // should always cause updates if they are consumed and then changed
      if (Array.isArray(value) || isEmberArray(value)) {
        update(propertyTag, tagForProperty(value, '[]'));
      }

      return value;
    },
github emberjs / ember.js / packages / @ember / -internals / metal / lib / computed.ts View on Github external
if (this._volatile) {
      return this.volatileSet(obj, keyName, value);
    }

    let ret;

    try {
      beginPropertyChanges();
      ret = this._set(obj, keyName, value);

      finishLazyChains(obj, keyName, ret);

      let propertyTag = tagForProperty(obj, keyName) as UpdatableTag;

      if (this._dependentKeys !== undefined) {
        update(propertyTag, combine(getChainTagsForKeys(obj, this._dependentKeys)));
      }

      setLastRevisionFor(obj, keyName, tagValue(propertyTag));
    } finally {
      endPropertyChanges();
    }

    return ret;
  }
github emberjs / ember.js / packages / @ember / -internals / metal / lib / chain-tags.ts View on Github external
if (lazyTags === undefined) {
    return;
  }

  if (value === null || (typeof value !== 'object' && typeof value !== 'function')) {
    for (let path in lazyTags) {
      delete lazyTags[path];
    }
    return;
  }

  for (let path in lazyTags) {
    let tag = lazyTags[path];

    update(tag, combine(getChainTagsForKey(value, path)));

    delete lazyTags[path];
  }
}
github emberjs / ember.js / packages / @ember / -internals / runtime / lib / mixins / -proxy.js View on Github external
export function contentFor(proxy, m) {
  let content = get(proxy, 'content');
  let tag = (m === undefined ? meta(proxy) : m).readableTag();
  if (tag !== undefined) {
    update(tag, tagFor(content));
  }
  return content;
}
github emberjs / ember.js / packages / @ember / -internals / glimmer / lib / helpers / get.ts View on Github external
compute() {
    let { lastPath, innerReference, innerTag } = this;
    let path = this.pathReference.value();

    if (path !== lastPath) {
      innerReference = referenceFromPath(this.sourceReference, path);
      update(innerTag, innerReference.tag);
      this.innerReference = innerReference;
      this.lastPath = path;
    }

    return innerReference.value();
  }
github emberjs / ember.js / packages / @ember / object / compat.ts View on Github external
desc.get = function() {
      let propertyTag = tagForProperty(this, key) as UpdatableTag;
      let ret;

      let tag = track(() => {
        ret = originalGet!.call(this);
      });

      update(propertyTag, tag);
      consume(tag);

      return ret;
    };
  }
github emberjs / ember.js / packages / @ember / -internals / glimmer / lib / modifiers / custom.ts View on Github external
install(state: CustomModifierState) {
    let { element, args, delegate, modifier, tag } = state;
    let { capabilities } = delegate;

    if (capabilities.disableAutoTracking === true) {
      untrack(() => delegate.installModifier(modifier, element, args.value()));
    } else {
      let combinedTrackingTag = track(
        () => delegate.installModifier(modifier, element, args.value()),
        DEBUG && debugRenderMessage!(`(instance of a \`${getDebugName!(modifier)}\` modifier)`)
      );

      update(tag, combinedTrackingTag);
    }
  }
github emberjs / ember.js / packages / @ember / -internals / glimmer / lib / modifiers / custom.ts View on Github external
update(state: CustomModifierState) {
    let { args, delegate, modifier, tag } = state;
    let { capabilities } = delegate;

    if (capabilities.disableAutoTracking === true) {
      untrack(() => delegate.updateModifier(modifier, args.value()));
    } else {
      let combinedTrackingTag = track(
        () => delegate.updateModifier(modifier, args.value()),
        DEBUG && debugRenderMessage!(`(instance of a \`${getDebugName!(modifier)}\` modifier)`)
      );
      update(tag, combinedTrackingTag);
    }
  }