You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+29Lines changed: 29 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,32 @@
1
+
<aname="1.0.0"></a>
2
+
# 1.0.0 (2014-10-17)
3
+
4
+
## Features
5
+
- You can now use multiple instances of localForage (see the [Readme file](https://github.com/ocombe/angular-localForage/blob/master/README.md) for more info).
6
+
- You can use a `name` option with bind and with the directive to specify which instance to use.
7
+
- Slightly better examples (I could do much better)
8
+
9
+
## Breaking changes
10
+
- The following deprecated functions have been removed: getDriver, set, get, remove, clearAll, getKeyAt, getLength
11
+
- getKeys is now deprecated, use the function keys instead (following the naming convention from localForage).
12
+
- Because localForage now takes into account the prefix for localStorage, this lib will no longer add its own prefix to localStorage variables.
13
+
If you want to ensure compability with values stored in localStorage before this release, you need to add `oldPrefix: true` to your provider's configuration:
14
+
```js
15
+
$localForageProvider.config({
16
+
oldPrefix:true
17
+
});
18
+
```
19
+
If you don't do that, you won't be able to access those old data, and they will stay in localStorage.
20
+
This doesn't affect other storages (indexedDB & WebSQL).
21
+
- The method `bind` and the directive have changed: `storeName` has been replaced by `scopeKey` to avoid confusion with the `storeName` from config and to be more self explicit. `key` is now the name of the storage key.
22
+
- The method `unbind` now takes only 2 parameters (scope & key, or scope & config object). `storeName` has also been replaced by `scopeKey`.
<inputlocal-forage="{key: 'autoStoredKey', name: 'myApp', scopeKey: 'myObj.myVar', defaultValue: 'this is the default value'}"ng-model="myObj.myVar"placeholder="This will be auto stored">
60
42
```
61
43
62
44
## Functions :
63
-
-```setDriver(driver)```: you can force the driver to use, check the [localForage documentation](https://github.com/mozilla/localForage#driver-selection-ie-forcing-localstorage) for more information
45
+
-`setDriver(driver)`: you can force the driver to use, check the [localForage documentation](https://github.com/mozilla/localForage#driver-selection-ie-forcing-localstorage) for more information
64
46
65
-
-```driver()```: returns the current localForage driver (sync)
47
+
-`driver()`: returns the current localForage driver (sync)
66
48
67
-
-```setItem(key, value)```: stores data (async, promise)
49
+
-`setItem(key, value)`: stores data (async, promise)
68
50
69
-
-```getItem(key)```: retrieves stored data (async, promise)
51
+
-`getItem(key)`: retrieves stored data (async, promise)
70
52
71
-
-```removeItem(key)```: removes stored data (async, promise)
53
+
-`removeItem(key)`: removes stored data (async, promise)
72
54
73
-
-```clear()```: removed all stored data for your application based on the app prefix (async, promise)
55
+
-`clear()`: removed all stored data for your application based on the app prefix (async, promise)
74
56
75
-
-```key(n)```: retrieves the key at n position in storage. Used internally for clearAll and getKeys functions. It doesn't take prefix into account (async, promise)
57
+
-`key(n)`: retrieves the key at n position in storage. It doesn't take the prefix into account if you use localStorage (async, promise)
76
58
77
-
-```getKeys(driver)```: returns all the keys used for storage in your application. Be careful with it if you use localstorage because it will return all the keys (not just the ones with your prefix) (async, promise)
59
+
-`keys()`: returns all the keys used for storage in your application (async, promise)
78
60
79
-
-```length(driver)```: returns the number of items stored. Used internally for clearAll and getKeys functions. Be careful with it if you use localstorage because it will return all the keys (not just the ones with your prefix) (async, promise)
61
+
-`length()`: returns the number of items stored (async, promise)
80
62
81
-
-```bind($scope, key/params object)```: lets you directly bind a LocalForage value to a $scope variable
63
+
-`bind($scope, key/params object)`: lets you directly bind a LocalForage value to a $scope variable (async, promise)
82
64
```js
83
-
$localForage.bind($scope, 'params');
65
+
$localForage.bind($scope, 'myStorageKey');
84
66
```
67
+
85
68
```js
86
69
$localForage.bind($scope, {
87
-
key:'params',
88
-
defaultValue: {test:'my test'},
89
-
storeName:'myStoreName'
70
+
key:'myStorageKey', // required
71
+
defaultValue: {test:'my test'}, // a default value
72
+
scopeKey:'myObj.myVar', // the name of the scope key (if you want it to be different from key)
73
+
name:'myApp'// instance name
90
74
});
91
75
```
92
76
93
-
-```unbind($scope, key[, storeName])```: lets you unbind a variable from localForage while removing the value from both
77
+
-`unbind($scope, key[, scopeKey])`: lets you unbind a variable from localForage while removing the value from both the scope and the storage (async, promise)
94
78
95
79
## Directive :
96
-
You can directly bind a scope value from within your html :
<inputlocal-forage="{key: 'autoStoredKey', name: 'myApp', scopeKey: 'myObj.myVar', defaultValue: 'this is the default value'}"ng-model="myObj.myVar"placeholder="This will be auto stored">
109
88
```
110
89
90
+
`key` is the only required parameter. The other options are:
91
+
-`name`: if you want to store your values in a specific instance (See [below](#multiple-instances) for more info on multiple instances)
92
+
-`scopeKey`: if you want to store the value in the scope under a different key from the one in storage. You can for example use a specific key of an object by using `myObj.myVar`
93
+
-`defaultValue`: if you want to define a ...default value
94
+
111
95
## Configure the provider :
112
-
You can configure the ```$localForageProvider``` to set your own prefix for storage. By default ```lf``` is used.
96
+
You can configure the `$localForageProvider`. Any parameter that you set here will be the default for any new localforage instance.
97
+
You can for example set your own prefix for storage (by default `lf` is used).
The parameters will inherit the default parameters that you might have configured in the config phase of your application (See [above](#configure-the-provider-) for details), but the new config object will overwrite them.
135
+
It means that you can have one instance using localStorage, and one instance using indexedDB/WebSQL, at the same time !
136
+
The instance will take the name that you will define in the config object. You can get an instance previously created by using the `instance` method:
137
+
```js
138
+
var lf2 =$localForage.instance('2nd');
139
+
```
140
+
141
+
The `instance` method will return the default instance if you don't give a name parameter.
142
+
144
143
## Unit tests
145
144
Download the required libs :
146
145
@@ -154,7 +153,7 @@ Then start the tests with :
154
153
npm test
155
154
```
156
155
157
-
It will launch Chrome and Firefox, edit karma.conf.js if you want to change something.
156
+
It will launch Chrome and Firefox, edit karma.conf.js if you want to change something. We could use more tests, see "contributing" below.
0 commit comments