Skip to content

Commit

Permalink
[CLEANUP] Remove ':change' suffix on change events
Browse files Browse the repository at this point in the history
  • Loading branch information
mmun committed Jan 25, 2018
1 parent dabdd89 commit b861ccc
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/ember-metal/lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
}
Expand Down
10 changes: 2 additions & 8 deletions packages/ember-metal/lib/observer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ import {
@module @ember/object
*/

const AFTER_OBSERVERS = ':change';

export function changeEvent(keyName) {
return keyName + AFTER_OBSERVERS;
}

/**
@method addObserver
@static
Expand All @@ -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;
Expand All @@ -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;
}
8 changes: 3 additions & 5 deletions packages/ember-metal/lib/property_events.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
} from 'ember/features';
import { deprecate } from 'ember-debug';
import { assertNotRendered } from './transaction';
import { changeEvent } from './observer';

/**
@module ember
Expand Down Expand Up @@ -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]);
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/ember-metal/tests/watching/unwatch_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/ember-metal/tests/watching/watch_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/ember-runtime/lib/mixins/observable.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ export default Mixin.create({
@private
*/
hasObserverFor(key) {
return hasListeners(this, `${key}:change`);
return hasListeners(this, key);
},

/**
Expand Down

0 comments on commit b861ccc

Please sign in to comment.