Skip to content

Commit 4576554

Browse files
committed
docs: multiple instances usage changed.
1 parent 0503e19 commit 4576554

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,33 @@ You can use multiple instances of localForage at the same time. To create a new
156156
name: '2nd',
157157
driver: 'localStorageWrapper'
158158
});
159+
160+
var lf3 = $localForage.createInstance({
161+
name: '3rd',
162+
storeName: 'kvpairs'
163+
});
159164
```
160165

161166
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.
162167
It means that you can have one instance using localStorage, and one instance using indexedDB/WebSQL, at the same time !
163168
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:
164169
```js
170+
// DEPRECATED
165171
var lf2 = $localForage.instance('2nd');
172+
173+
// NEW USAGE
174+
var lf2 = $localForage.instance({
175+
name: '2nd'
176+
});
177+
178+
var lf3 = $localForage.instance({
179+
name: '3rd',
180+
storeName: 'kvpairs'
181+
});
182+
183+
var lf4 = $localForage.instance({
184+
storeName: 'example_store'
185+
});
166186
```
167187

168188
The `instance` method will return the default instance if you don't give a name parameter.

0 commit comments

Comments
 (0)