From dbcd2457081251f703f3440ce76b2ab0f8d459d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Wo=C5=BAny?= Date: Tue, 16 Nov 2021 18:49:37 +0100 Subject: [PATCH] chore: avoid using getWithDefault --- addon/services/resize.ts | 4 ++-- app/initializers/resize.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/addon/services/resize.ts b/addon/services/resize.ts index 558ea620..9d2307b3 100644 --- a/addon/services/resize.ts +++ b/addon/services/resize.ts @@ -1,4 +1,4 @@ -import { computed, getWithDefault, set } from '@ember/object'; +import { computed, get, set } from '@ember/object'; import Evented from '@ember/object/evented'; import { cancel, debounce } from '@ember/runloop'; import Service from '@ember/service'; @@ -55,7 +55,7 @@ class ResizeService extends Service.extend(Evented, { } public _setDefaults() { - const defaults = getWithDefault(this, 'resizeServiceDefaults', {} as any); + const defaults = (get(this, 'resizeServiceDefaults') === undefined ? {} as any : get(this, 'resizeServiceDefaults')); Object.keys(defaults).map((key: keyof ResizeDefaults) => { const classifiedKey = classify(key); diff --git a/app/initializers/resize.ts b/app/initializers/resize.ts index d51f3f91..d12af96c 100644 --- a/app/initializers/resize.ts +++ b/app/initializers/resize.ts @@ -1,16 +1,16 @@ // eslint-disable-next-line no-unused-vars import Application from '@ember/application'; -import { getWithDefault } from '@ember/object'; +import { get } from '@ember/object'; import ResizeService from 'ember-resize/services/resize'; import config from '../config/environment'; export function initialize(application: Pick) { - const resizeServiceDefaults = getWithDefault(config, 'resizeServiceDefaults', { + const resizeServiceDefaults = (get(config, 'resizeServiceDefaults') === undefined ? { debounceTimeout: 200, heightSensitive: true, widthSensitive: true, - }); - const injectionFactories = getWithDefault(resizeServiceDefaults, 'injectionFactories', ['view', 'component']) || []; + } : get(config, 'resizeServiceDefaults')); + const injectionFactories = (get(resizeServiceDefaults, 'injectionFactories') === undefined ? ['view', 'component'] : get(resizeServiceDefaults, 'injectionFactories')) || []; application.unregister('config:resize-service');