From fe50098bfc8f4455fec573a003abdef8f86967cc Mon Sep 17 00:00:00 2001 From: Andreas Minnich Date: Tue, 28 Jan 2020 16:39:22 +0100 Subject: [PATCH] Set observers explicitly to be sync to support Ember 3.13+ --- addon/create-class-computed.js | 44 ++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/addon/create-class-computed.js b/addon/create-class-computed.js index 893891a..ceb88c3 100644 --- a/addon/create-class-computed.js +++ b/addon/create-class-computed.js @@ -51,25 +51,29 @@ function findOrCreatePropertyInstance(context, propertyClass, key, cp) { const BaseClass = EmberObject.extend({ // eslint-disable-next-line ember/no-observers - computedDidChange: observer('computed', function() { - let { - context, - key, - preventDoubleRender - } = this; - - if (context.isDestroying) { - // controllers can get into this state - this.destroy(); - - return; - } + computedDidChange: observer({ + dependentKeys: ['computed'], + fn() { + let { + context, + key, + preventDoubleRender + } = this; + + if (context.isDestroying) { + // controllers can get into this state + this.destroy(); + + return; + } - if (preventDoubleRender) { - return; - } + if (preventDoubleRender) { + return; + } - context.notifyPropertyChange(key); + context.notifyPropertyChange(key); + }, + sync: true }) }); @@ -123,7 +127,11 @@ export default function(observerBools, macroGenerator) { mappedKeys.push(mappedKey); if (shouldObserve) { // eslint-disable-next-line ember/no-observers - classProperties[`key${i}DidChange`] = observer(mappedKey, rewriteComputed); + classProperties[`key${i}DidChange`] = observer({ + dependentKeys: [mappedKey], + fn: rewriteComputed, + sync: true + }); } });