UNPKG

ember-legacy-class-transform

Version:
41 lines 1.23 kB
import Meta from '../meta'; import { VOLATILE_TAG } from '@glimmer/reference'; export class PropertyReference { constructor(object, property, _outer) { this.tag = VOLATILE_TAG; this.object = object; this.property = property; } value() { return this.object[this.property]; } label() { return '[reference Property]'; } } export function ComputedReferenceBlueprint(_property, dependencies) { return class ComputedReference { constructor(object, property, outer) { this.installed = false; this.tag = VOLATILE_TAG; this.object = object; this.property = property; this.dependencies = dependencies; this.outer = outer; } value() { if (!this.installed) { let root = Meta.for(this.object).root(); this.dependencies.forEach(dep => { let ref = root.referenceFromParts(dep); ref.value(); }); this.installed = true; } return this.object[this.property]; } label() { return '[reference Computed]'; } }; }