4761277fd0
1. The factory is taken from the ember source, but makes it more reusable 2. Purify converts conventional ember `computed` into a pure version This commit only adds new files that could be used further down the line
19 lines
695 B
JavaScript
19 lines
695 B
JavaScript
/**
|
|
* Gives you factory function to create a specified type of ComputedProperty
|
|
* Largely taken from https://github.com/emberjs/ember.js/blob/v2.18.2/packages/ember-metal/lib/computed.js#L529
|
|
* but configurable from the outside (IoC) so its reuseable
|
|
*
|
|
* @param {Class} ComputedProperty - ComputedProperty to use for the factory
|
|
* @returns {function} - Ember-like `computed` function (see https://www.emberjs.com/api/ember/2.18/classes/ComputedProperty)
|
|
*/
|
|
export default function(ComputedProperty) {
|
|
return function() {
|
|
const args = [...arguments];
|
|
const cp = new ComputedProperty(args.pop());
|
|
if (args.length > 0) {
|
|
cp.property(...args);
|
|
}
|
|
return cp;
|
|
};
|
|
}
|