Skip to content

Commit

Permalink
fix: use object spread operator to replace Ember.assign and fix depre…
Browse files Browse the repository at this point in the history
…cation (#12)
  • Loading branch information
fusion2004 committed Jul 12, 2022
1 parent 4e49fdb commit 43a2358
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
5 changes: 1 addition & 4 deletions addon/-private/utils/prepare-options.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { assign } from '@ember/polyfills';


// Prepares options for template helpers
export default function prepareOptions(options) {
let newOptions = assign({silenceErrors: true}, options);
let newOptions = { silenceErrors: true, ...options };
// newOptions.remote = remote;
// if (!newOptions.metadata) {
// newOptions.metadata = metadata;
Expand Down
23 changes: 10 additions & 13 deletions addon/services/stereo.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
waitForEvent,
didCancel,
} from 'ember-concurrency';
import { assign } from '@ember/polyfills';
import { cancel, later, next } from '@ember/runloop';
import { isTesting, macroCondition } from '@embroider/macros';
import canAutoplay from 'can-autoplay';
Expand Down Expand Up @@ -364,16 +363,14 @@ export default class Stereo extends Service.extend(EmberEvented) {
*/

prepareLoadOptions(options) {
return assign(
{
metadata: {},
sharedAudioAccess: this._createAndUnlockAudio(),
useSharedAudioAccess: this.useSharedAudioAccess,
isMobileDevice: this.isMobileDevice,
connections: this.connectionLoader.connections,
},
options
);
return {
metadata: {},
sharedAudioAccess: this._createAndUnlockAudio(),
useSharedAudioAccess: this.useSharedAudioAccess,
isMobileDevice: this.isMobileDevice,
connections: this.connectionLoader.connections,
...options,
};
}

@task({ restartable: true, evented: true })
Expand Down Expand Up @@ -496,7 +493,7 @@ export default class Stereo extends Service.extend(EmberEvented) {
*/

load(urlsOrPromise, options) {
options = assign({ metadata: {} }, options);
options = { metadata: {}, ...options };

try {
let promise = this.loadTask.perform(urlsOrPromise, options);
Expand Down Expand Up @@ -527,7 +524,7 @@ export default class Stereo extends Service.extend(EmberEvented) {

@task({ restartable: true })
*playTask(urlsOrPromise, options = {}) {
options = assign({ metadata: {} }, options);
options = { metadata: {}, ...options };

let previouslyPlayingSound = this.isPlaying ? this.currentSound : false;

Expand Down

0 comments on commit 43a2358

Please sign in to comment.