How to use the @glimmer/tracking.tracked function in @glimmer/tracking

To help you get started, we’ve selected a few @glimmer/tracking 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 pzuraq / tracked-built-ins / addon / -private / decorator.ts View on Github external
function tracked(target: object, key: string, desc: PropertyDescriptor) {
  let initializer = (desc as any).initializer;
  let trackedDesc = glimmerTracked(target, key, desc);
  let { get: originalGet, set: originalSet } = trackedDesc;

  let defaultAssigned = new WeakSet();

  function set(this: any, value: unknown) {
    if (typeof value === 'object' && value !== null) {
      if (value instanceof Map) {
        value = new TrackedMap(value);
      } else if (value instanceof WeakMap) {
        value = new TrackedWeakMap();
      } else if (value instanceof Set) {
        value = new TrackedSet(value);
      } else if (value instanceof WeakSet) {
        value = new TrackedWeakSet();
      }
    }

@glimmer/tracking

Glimmer property tracking library

MIT
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis

Popular @glimmer/tracking functions