From b861ccc93ac8dee15c4e58c10ebada28bc85f503 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Mu=C3=B1oz?= Date: Wed, 24 Jan 2018 21:21:19 -0500 Subject: [PATCH] [CLEANUP] Remove ':change' suffix on change events --- packages/ember-metal/lib/events.js | 2 +- packages/ember-metal/lib/observer.js | 10 ++-------- packages/ember-metal/lib/property_events.js | 8 +++----- packages/ember-metal/tests/watching/unwatch_test.js | 2 +- packages/ember-metal/tests/watching/watch_test.js | 2 +- packages/ember-runtime/lib/mixins/observable.js | 2 +- 6 files changed, 9 insertions(+), 17 deletions(-) diff --git a/packages/ember-metal/lib/events.js b/packages/ember-metal/lib/events.js index a1f12a147f1..688a117cd95 100644 --- a/packages/ember-metal/lib/events.js +++ b/packages/ember-metal/lib/events.js @@ -17,7 +17,7 @@ import { ONCE, SUSPENDED } from './meta_listeners'; // Object's meta hash { listeners: { // variable name: `listenerSet` - "foo:changed": [ // variable name: `actions` + "foo": [ // variable name: `actions` target, method, flags ] } diff --git a/packages/ember-metal/lib/observer.js b/packages/ember-metal/lib/observer.js index 6bbda454c99..e74ba46ab9e 100644 --- a/packages/ember-metal/lib/observer.js +++ b/packages/ember-metal/lib/observer.js @@ -10,12 +10,6 @@ import { @module @ember/object */ -const AFTER_OBSERVERS = ':change'; - -export function changeEvent(keyName) { - return keyName + AFTER_OBSERVERS; -} - /** @method addObserver @static @@ -27,7 +21,7 @@ export function changeEvent(keyName) { @public */ export function addObserver(obj, _path, target, method) { - addListener(obj, changeEvent(_path), target, method); + addListener(obj, _path, target, method); watch(obj, _path); return this; @@ -45,7 +39,7 @@ export function addObserver(obj, _path, target, method) { */ export function removeObserver(obj, path, target, method) { unwatch(obj, path); - removeListener(obj, changeEvent(path), target, method); + removeListener(obj, path, target, method); return this; } diff --git a/packages/ember-metal/lib/property_events.js b/packages/ember-metal/lib/property_events.js index 6f3427b662d..ccbac49fd97 100644 --- a/packages/ember-metal/lib/property_events.js +++ b/packages/ember-metal/lib/property_events.js @@ -15,7 +15,6 @@ import { } from 'ember/features'; import { deprecate } from 'ember-debug'; import { assertNotRendered } from './transaction'; -import { changeEvent } from './observer'; /** @module ember @@ -258,12 +257,11 @@ function accumulateListeners(obj, eventName, otherActions, meta) { function notifyObservers(obj, keyName, meta) { if (meta.isSourceDestroying()) { return; } - let eventName = changeEvent(keyName); if (deferred > 0) { - let listeners = observerSet.add(obj, keyName, eventName); - accumulateListeners(obj, eventName, listeners, meta); + let listeners = observerSet.add(obj, keyName, keyName); + accumulateListeners(obj, keyName, listeners, meta); } else { - sendEvent(obj, eventName, [obj, keyName]); + sendEvent(obj, keyName, [obj, keyName]); } } diff --git a/packages/ember-metal/tests/watching/unwatch_test.js b/packages/ember-metal/tests/watching/unwatch_test.js index 455b4176cda..5777e17b6a6 100644 --- a/packages/ember-metal/tests/watching/unwatch_test.js +++ b/packages/ember-metal/tests/watching/unwatch_test.js @@ -14,7 +14,7 @@ import { let didCount; function addListeners(obj, keyPath) { - addListener(obj, keyPath + ':change', () => didCount++); + addListener(obj, keyPath, () => didCount++); } moduleFor('unwatch', class extends AbstractTestCase { diff --git a/packages/ember-metal/tests/watching/watch_test.js b/packages/ember-metal/tests/watching/watch_test.js index 4f11c7457c7..4faccc8c61f 100644 --- a/packages/ember-metal/tests/watching/watch_test.js +++ b/packages/ember-metal/tests/watching/watch_test.js @@ -18,7 +18,7 @@ import { let didCount, didKeys, originalLookup; function addListeners(obj, keyPath) { - addListener(obj, keyPath + ':change', function() { + addListener(obj, keyPath, function() { didCount++; didKeys.push(keyPath); }); diff --git a/packages/ember-runtime/lib/mixins/observable.js b/packages/ember-runtime/lib/mixins/observable.js index f6c311f9c4b..c931e4148ea 100644 --- a/packages/ember-runtime/lib/mixins/observable.js +++ b/packages/ember-runtime/lib/mixins/observable.js @@ -386,7 +386,7 @@ export default Mixin.create({ @private */ hasObserverFor(key) { - return hasListeners(this, `${key}:change`); + return hasListeners(this, key); }, /**