I've got a function that I'd like to be able to create a series of properties on the class that calls it. I want to be able to get the name of the property that the implementor sets this to, i.e.:
// utils/attachable.js
export function attachable() {
let key = 'how do I get this to be "images"';
};
// models/resource.js
import DS from 'ember-data';
import Model from './base';
import { attachable } from 'doki/utils/attachable';
let attr = DS.attr;
export default Model.extend({
images: attachable()
});
In this example, if the implementor defines the property "images" and assigns the attachable method to it, I want to be able to get the name of that property "images" in the attachable method and then do some stuff on that class using that key. Is this possible in javascript?
Aucun commentaire:
Enregistrer un commentaire