forked from marcj/angular2-localstorage
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
release(v0.6.0): add config previousPrefix for backward compatibility…
… and safe config changes, update README, provide better functions accessibility, minor fixes and code improvements
- Loading branch information
1 parent
2067f93
commit 8968429
Showing
6 changed files
with
99 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "ngx-store", | ||
"version": "0.5.4", | ||
"version": "0.6.0", | ||
"main": "./dist/index", | ||
"typings": "./dist/index", | ||
"description": "Angular decorator to save and restore class properties automatically from LocalStorage and SessionStorage.", | ||
|
@@ -12,20 +12,20 @@ | |
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "[email protected]:zoomsphere/angular2-localstorage.git" | ||
"url": "[email protected]:zoomsphere/ngx-store.git" | ||
}, | ||
"keywords": [ | ||
"Angular2", | ||
"LocalStorage", | ||
"SessionStorage", | ||
"Storage" | ||
], | ||
"author": "Marc J. Schmidt", | ||
"author": "Daniel Kucal & Marc J. Schmidt", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/zoomsphere/angular2-localstorage/issues" | ||
"url": "https://github.com/zoomsphere/ngx-store/issues" | ||
}, | ||
"homepage": "https://github.com/zoomsphere/angular2-localstorage", | ||
"homepage": "https://github.com/zoomsphere/ngx-store", | ||
"peerDependencies": { | ||
"@angular/core": ">=2.3.0", | ||
"core-js": "^2.4.1", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,37 @@ | ||
import { WebStorageConfigInterface } from './config.interface'; | ||
import { ConfigHelper } from './config.helper'; | ||
|
||
// TODO allow to set different config for local and session storage | ||
// TODO check if NGXSTORE_CONFIG implements WebStorageConfigInterface | ||
// TODO allow to set configuration in node-config (`config` on npm) | ||
|
||
const DefaultConfig: WebStorageConfigInterface = { | ||
prefix: 'angular2_ws', // TODO: change default to 'ngx_' | ||
clearType: 'decorators', // TODO: change default to 'prefix' | ||
mutateObjects: true | ||
prefix: 'ngx_', | ||
previousPrefix: 'angular2ws_', | ||
clearType: 'prefix', | ||
mutateObjects: true, | ||
}; | ||
|
||
// TODO allow to set configuration in node-config (`config` on npm) | ||
// take configuration provided as a global variable | ||
declare const NGXSTORE_CONFIG: WebStorageConfigInterface; | ||
|
||
let ConfigFills: WebStorageConfigInterface = {}; | ||
let localStoragePrefix = ConfigHelper.getItem('prefix'); | ||
if (localStoragePrefix) { | ||
ConfigFills.previousPrefix = localStoragePrefix; | ||
} else if (NGXSTORE_CONFIG && NGXSTORE_CONFIG.previousPrefix !== undefined) { | ||
ConfigFills.previousPrefix = NGXSTORE_CONFIG.previousPrefix; | ||
} else { | ||
ConfigFills.previousPrefix = DefaultConfig.previousPrefix; | ||
} | ||
|
||
/** | ||
* @deprecated define global variable `NGXSTORE_CONFIG` instead | ||
*/ | ||
export const WEBSTORAGE_CONFIG = DefaultConfig; | ||
export let WEBSTORAGE_CONFIG = DefaultConfig; | ||
|
||
// merge default config, deprecated config and global config all together | ||
export const Config = Object.assign({}, DefaultConfig, WEBSTORAGE_CONFIG, NGXSTORE_CONFIG); | ||
export const Config: WebStorageConfigInterface = | ||
Object.assign({}, DefaultConfig, WEBSTORAGE_CONFIG, NGXSTORE_CONFIG, ConfigFills); | ||
|
||
ConfigHelper.setItem('prefix', Config.prefix); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters