Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: avoid using getWithDefault #365

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions addon/services/resize.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions app/initializers/resize.ts
Original file line number Diff line number Diff line change
@@ -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<Application, 'register'|'inject'|'unregister'|'resolveRegistration'>) {
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');

Expand Down