Skip to content

Commit

Permalink
Merge pull request #15932 from bekzod/reuse-event-name-constructors
Browse files Browse the repository at this point in the history
reuse event name constructors
  • Loading branch information
rwjblue authored Dec 7, 2017
2 parents 3fa2562 + 0b703c0 commit e1dc61f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/ember-metal/lib/observer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import {
const AFTER_OBSERVERS = ':change';
const BEFORE_OBSERVERS = ':before';

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

function beforeEvent(keyName) {
export function beforeEvent(keyName) {
return keyName + BEFORE_OBSERVERS;
}

Expand Down
5 changes: 3 additions & 2 deletions packages/ember-metal/lib/property_events.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
EMBER_GLIMMER_DETECT_BACKTRACKING_RERENDER,
} from 'ember/features';
import { assertNotRendered } from './transaction';
import { changeEvent, beforeEvent } from './observer';

/**
@module ember
Expand Down Expand Up @@ -283,7 +284,7 @@ function accumulateListeners(obj, eventName, otherActions, meta) {
function notifyBeforeObservers(obj, keyName, meta) {
if (meta.isSourceDestroying()) { return; }

let eventName = `${keyName}:before`;
let eventName = beforeEvent(keyName);
let listeners, added;
if (deferred > 0) {
listeners = beforeObserverSet.add(obj, keyName, eventName);
Expand All @@ -295,7 +296,7 @@ function notifyBeforeObservers(obj, keyName, meta) {
function notifyObservers(obj, keyName, meta) {
if (meta.isSourceDestroying()) { return; }

let eventName = `${keyName}:change`;
let eventName = changeEvent(keyName);
let listeners;
if (deferred > 0) {
listeners = observerSet.add(obj, keyName, eventName);
Expand Down

0 comments on commit e1dc61f

Please sign in to comment.