Skip to content

Commit

Permalink
[BUGFIX beta] Deprecate Array/Reduce computed
Browse files Browse the repository at this point in the history
  • Loading branch information
cibernox committed Jun 11, 2015
1 parent 0118d09 commit 30817b7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/ember-runtime/lib/computed/array_computed.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ var a_slice = [].slice;
function ArrayComputedProperty() {
var cp = this;

this._isArrayComputed = true;
ReduceComputedProperty.apply(this, arguments);

this._getter = (function(reduceFunc) {
Expand Down Expand Up @@ -163,6 +164,7 @@ ArrayComputedProperty.prototype.didChange = function (obj, keyName) {
@param {String} [dependentKeys*]
@param {Object} options
@return {Ember.ComputedProperty}
@deprecated
@private
*/
function arrayComputed(options) {
Expand Down
7 changes: 7 additions & 0 deletions packages/ember-runtime/lib/computed/reduce_computed.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,12 @@ export { ReduceComputedProperty }; // TODO: default export
function ReduceComputedProperty(options) {
var cp = this;

if (this._isArrayComputed) {
Ember.deprecate('Ember.arrayComputed is deprecated. Replace it with plain array methods');
} else {
Ember.deprecate('Ember.reduceComputed is deprecated. Replace it with plain array methods');
}

this.options = options;
this._dependentKeys = null;
this._cacheable = true;
Expand Down Expand Up @@ -841,6 +847,7 @@ ReduceComputedProperty.prototype.property = function () {
@param {String} [dependentKeys*]
@param {Object} options
@return {Ember.ComputedProperty}
@deprecated
@public
*/
export function reduceComputed(options) {
Expand Down
9 changes: 9 additions & 0 deletions packages/ember-runtime/tests/computed/reduce_computed_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ QUnit.module('arrayComputed', {
}
});

QUnit.test("reduceComputed is deprecated", function() {
expectDeprecation(/Ember.reduceComputed is deprecated/);
reduceComputed({ initialValue: 0 });
});

QUnit.test("arrayComputed is deprecated", function() {
expectDeprecation(/Ember.arrayComputed is deprecated/);
arrayComputed({});
});

QUnit.test("array computed properties are instances of ComputedProperty", function() {
ok(arrayComputed({}) instanceof ComputedProperty);
Expand Down

0 comments on commit 30817b7

Please sign in to comment.