Function

Module: @ember/object
meta
Object

In some cases, you may want to annotate computed properties with additional metadata about how they function or what values they operate on. For example, computed property functions may close over variables that are then no longer available for introspection.

You can pass a hash of these values to a computed property like this:

1
2
3
4
5
6
7
import { computed } from '@ember/object';
import Person from 'my-app/utils/person';

person: computed(function() {
  let personId = this.get('personId');
  return Person.create({ id: personId });
}).meta({ type: Person })

The hash that you pass to the meta() function will be saved on the computed property descriptor under the _meta key. Ember runtime exposes a public API for retrieving these values from classes, via the metaForProperty() function.