Skip to content

Commit

Permalink
remove rewatch
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanpenner committed Oct 15, 2014
1 parent fbf91df commit 4cb94d7
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 73 deletions.
28 changes: 1 addition & 27 deletions packages/ember-metal/lib/watching.js
Expand Up @@ -3,9 +3,7 @@
*/

import {
GUID_KEY,
typeOf,
generateGuid
typeOf
} from "ember-metal/utils";
import {
removeChainWatcher,
Expand Down Expand Up @@ -68,30 +66,6 @@ export function unwatch(obj, _keyPath, m) {
}
}

/**
Call on an object when you first beget it from another object. This will
setup any chained watchers on the object instance as needed. This method is
safe to call multiple times.
@private
@method rewatch
@for Ember
@param obj
*/
export function rewatch(obj) {
var m = obj['__ember_meta__'], chains = m && m.chains;

// make sure the object has its own guid.
if (GUID_KEY in obj && !obj.hasOwnProperty(GUID_KEY)) {
generateGuid(obj);
}

// make sure any chained watchers update.
if (chains && chains.value() !== obj) {
m.chains = chains.copy(obj);
}
}

var NODE_STACK = [];

/**
Expand Down
27 changes: 0 additions & 27 deletions packages/ember-metal/tests/binding/connect_test.js
Expand Up @@ -5,10 +5,8 @@ import {
bind
} from "ember-metal/binding";
import run from 'ember-metal/run_loop';
import { create } from 'ember-metal/platform';
import { set } from 'ember-metal/property_set';
import { get } from 'ember-metal/property_get';
import { rewatch } from "ember-metal/watching";

function performTest(binding, a, b, get, set, connect) {
if (connect === undefined) connect = function() {binding.connect(a);};
Expand Down Expand Up @@ -104,31 +102,6 @@ testBoth('Calling connect more than once', function(get, set) {
});
});

testBoth('Bindings should be inherited', function(get, set) {

var a = { foo: 'FOO', b: { bar: 'BAR' } };
var binding = new Binding('foo', 'b.bar');
var a2;

run(function () {
binding.connect(a);

a2 = create(a);
rewatch(a2);
});

equal(get(a2, 'foo'), "BAR", "Should have synced binding on child");
equal(get(a, 'foo'), "BAR", "Should NOT have synced binding on parent");

run(function () {
set(a2, 'b', { bar: 'BAZZ' });
});

equal(get(a2, 'foo'), "BAZZ", "Should have synced binding on child");
equal(get(a, 'foo'), "BAR", "Should NOT have synced binding on parent");

});

test('inherited bindings should sync on create', function() {
var a;
run(function () {
Expand Down
17 changes: 0 additions & 17 deletions packages/ember-metal/tests/utils/guidFor_test.js
@@ -1,7 +1,6 @@
import {
guidFor
} from "ember-metal/utils";
import { rewatch } from "ember-metal/watching";

QUnit.module("guidFor");

Expand All @@ -27,22 +26,6 @@ test("Object", function() {
nanGuid( a );
});

test("Object with prototype", function() {
var Class = function() { };

guidFor(Class.prototype);

var a = new Class();
var b = new Class();

sameGuid( a, b , "without calling rewatch, objects copy the guid from their prototype");

rewatch(a);
rewatch(b);

diffGuid( a, b, "after calling rewatch, objects don't share guids" );
});

test("strings", function() {
var a = "string A";
var aprime = "string A";
Expand Down
2 changes: 0 additions & 2 deletions packages/ember-runtime/lib/system/core_object.js
Expand Up @@ -20,7 +20,6 @@ import {
meta,
makeArray
} from "ember-metal/utils";
import { rewatch } from "ember-metal/watching";
import { finishChains } from "ember-metal/chains";
import { sendEvent } from "ember-metal/events";
import {
Expand Down Expand Up @@ -196,7 +195,6 @@ function makeCtor() {
if (!wasApplied) {
wasApplied = true;
Class.PrototypeMixin.applyPartial(Class.prototype);
rewatch(Class.prototype);
}

return this.prototype;
Expand Down

0 comments on commit 4cb94d7

Please sign in to comment.