Skip to content
Permalink
Browse files

fix(settings): simplify storageFor decorator

  • Loading branch information...
devinus committed Sep 12, 2018
1 parent 961914a commit ea0749ef82c1c233c1e1a08875ca49f15f07bf26
Showing with 8 additions and 6 deletions.
  1. +3 −5 app/decorators.js
  2. +5 −1 app/settings/service.js
@@ -2,11 +2,9 @@ import { storageFor } from 'ember-local-storage';

import { computedDecoratorWithParams } from '@ember-decorators/utils/computed';

export const storage = computedDecoratorWithParams((target, key, desc, params = []) => {
const options = params[params.length - 1] || {};
const storageKey = options.key || key;
return storageFor(storageKey, ...params.slice(1));
});
const storageDecorator = (target, key, desc, params = []) => storageFor(key, ...params);

export const storage = computedDecoratorWithParams(storageDecorator);

export default {
storage,
@@ -1,9 +1,13 @@
import ObjectProxy from '@ember/object/proxy';

import { alias } from '@ember-decorators/object/computed';

import { storage } from '../decorators';

export default class SettingsService extends ObjectProxy {
@storage({ key: 'settings' }) content = null;
@storage() settings = null;

@alias('settings') content = null;

static isServiceFactory = true;
}

0 comments on commit ea0749e

Please sign in to comment.
You can’t perform that action at this time.