diff --git a/README.md b/README.md index 78b56b2b..4c6bf997 100644 --- a/README.md +++ b/README.md @@ -164,7 +164,7 @@ export default Ember.Component.extend({ `model` Optional string - The dependent property. Must be an ember data model or an object with `modelName` and `id` properties. (It is still experimental) `options` are: -- `legacyKey` String +- `legacyKey` String - **Deprecated see [Deprecations](#deprecations)** #### Methods @@ -391,6 +391,15 @@ export default Route.extend({ - `download` Boolean (default `false`) - `filename` String (default ember-data.json) +## Deprecations + +### storageFor - legacyKey +until: 2.0.0 + +id: ember-local-storage.storageFor.options.legacyKey + +Using `legacyKey` has been deprecated and will be removed in version 2.0.0. You should migrate your key to the new format. For `storageFor('settings')` that would be `storage:settings`. + ## Running * `ember serve` diff --git a/addon/helpers/storage.js b/addon/helpers/storage.js index 286f82af..2ddd9b0f 100644 --- a/addon/helpers/storage.js +++ b/addon/helpers/storage.js @@ -6,7 +6,8 @@ const { getOwner, String: { dasherize - } + }, + deprecate } = Ember; const assign = Ember.assign || Ember.merge; @@ -38,6 +39,7 @@ function getStorage(name) { let storages = {}; +// TODO: v2.0 - Remove options function storageFor(key, modelName, options = {}) { if (arguments.length === 2 && typeof modelName === 'object') { options = modelName; @@ -85,6 +87,7 @@ function storageFor(key, modelName, options = {}) { * Looks up the storage factory on the container and sets initial state * on the instance if desired. */ +// TODO: v2.0 - Remove options and legacyKey function createStorage(context, key, modelKey, options) { const owner = getOwner(context); const factoryType = 'storage'; @@ -95,6 +98,12 @@ function createStorage(context, key, modelKey, options) { owner.registerOptionsForType(factoryType, { instantiate: false }); if (options.legacyKey) { + deprecate('Using legacyKey has been deprecated and will be removed in version 2.0.0', false, { + id: 'ember-local-storage.storageFor.options.legacyKey', + until: '2.0.0', + url: 'https://github.com/funkensturm/ember-local-storage#deprecations' + }); + storageKey = options.legacyKey; } else { storageKey = modelKey ? `${storageFactory}:${modelKey}` : storageFactory;