Skip to content

v8 #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 190 commits into from
May 28, 2019
Merged

v8 #76

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
190 commits
Select commit Hold shift + click to select a range
f402492
feat: new JSONSchem, and shortcuts and auto-inference for basic types
cyrilletuzi Jan 27, 2019
a88cab4
revert: remove shortcuts
cyrilletuzi Jan 27, 2019
582f972
tests: fix typo
cyrilletuzi Jan 27, 2019
1b614fa
test: test json schema standard support
cyrilletuzi Jan 27, 2019
e3df460
tests: remove unecessary casts
cyrilletuzi Jan 27, 2019
d274bfd
merge commit
cyrilletuzi Jan 27, 2019
199c57b
doc: documentation for v8 validation
cyrilletuzi Jan 27, 2019
ce1ff45
doc: delete old statement
cyrilletuzi Jan 27, 2019
6e70771
tests: fix const tests
cyrilletuzi Jan 27, 2019
8ce0a87
feat: update to TS 3.2
cyrilletuzi Jan 27, 2019
f518717
feat: update peerDependencies to Angular 8 and RxJS 6.3
cyrilletuzi Jan 28, 2019
78c9f5e
revert: rxjs peer 6.0
cyrilletuzi Jan 28, 2019
8163bac
fix: minor updates
cyrilletuzi Jan 28, 2019
2da53df
fix: remove unused deps
cyrilletuzi Jan 28, 2019
5cba136
feat: Angular 8.0.0-beta.1
cyrilletuzi Jan 28, 2019
cd97f1d
build: next tag for beta
cyrilletuzi Jan 28, 2019
022a7a6
docs: update README to v8
cyrilletuzi Jan 28, 2019
60bede9
doc: info about maintenance
cyrilletuzi Jan 28, 2019
47231e5
deps: update to latest beta, pin ts to minor and tsickle to patch
cyrilletuzi Feb 4, 2019
c576497
docs: flag specific JSONSchema interfaces as to be ignored
cyrilletuzi Feb 4, 2019
e13f4f8
Merge branch 'newjsonschema' into v8beta
cyrilletuzi Feb 4, 2019
848a205
docs: migration guide to v8
cyrilletuzi Feb 4, 2019
e8cf02b
feat: disallow null or undefined in setItem
cyrilletuzi Feb 4, 2019
ae91e8f
docs: changelog for v8.0.0-beta.0
cyrilletuzi Feb 4, 2019
8bd2742
lint
cyrilletuzi Feb 4, 2019
5742b25
Merge branch 'nonullorundefined' into v8beta
cyrilletuzi Feb 4, 2019
f94e64e
fix: align app test to new schema
cyrilletuzi Feb 4, 2019
7af8cdf
tests: update to latest tools
cyrilletuzi Feb 5, 2019
1daf1be
feat: allow custom indexeddb database and store names (#78)
cyrilletuzi Feb 5, 2019
4cd56c8
docs: indexeddb db and store names doc
cyrilletuzi Feb 5, 2019
dcaaf2a
refactor: indexeddb
cyrilletuzi Feb 5, 2019
f20d423
docs: info about special chars in options
cyrilletuzi Feb 6, 2019
eea6792
refactor: rename indexedb things
cyrilletuzi Feb 6, 2019
a8d176a
refactor: rename IDB things
cyrilletuzi Feb 6, 2019
054dae7
docs: indentify all storage scenarios
cyrilletuzi Feb 6, 2019
31a272a
refactor: localstorage
cyrilletuzi Feb 6, 2019
57dbf40
refactor: mock storage
cyrilletuzi Feb 6, 2019
c627cdf
refactor: rename mock to memory
cyrilletuzi Feb 6, 2019
717760f
docs
cyrilletuzi Feb 6, 2019
b7f9e78
refactor: jsonvalidator
cyrilletuzi Feb 6, 2019
7278f4c
refactor: main service
cyrilletuzi Feb 6, 2019
32ce819
tests: remove useless validator tests
cyrilletuzi Feb 6, 2019
928c0b1
tests: align to new error message
cyrilletuzi Feb 6, 2019
b2e12e6
feat: better error management and move idb fallback to main service
cyrilletuzi Feb 6, 2019
c0cf472
internal: reduce surface api
cyrilletuzi Feb 6, 2019
02f9144
docs: remove some done todos
cyrilletuzi Feb 6, 2019
ac58b7c
docs: how to force a standard json schema
cyrilletuzi Feb 6, 2019
62711bc
refactor: validator tests
cyrilletuzi Feb 6, 2019
5cb6161
refator: storages tests
cyrilletuzi Feb 6, 2019
26fbeee
feat: export default IDB database and store names
cyrilletuzi Feb 6, 2019
d745ffe
tests
cyrilletuzi Feb 6, 2019
d682737
release: v8.0.0-beta.2
cyrilletuzi Feb 6, 2019
22e40eb
cleanup: remove unecessary e2e project
cyrilletuzi Feb 6, 2019
0b323f1
lint
cyrilletuzi Feb 6, 2019
482fc56
tests: clear localStorage directly
cyrilletuzi Feb 6, 2019
ea82032
docs: add references to issues
cyrilletuzi Feb 7, 2019
dd0eca6
refactor: explicit conditions
cyrilletuzi Feb 7, 2019
04e77cd
docs: add todo
cyrilletuzi Feb 7, 2019
63c26ff
tests: clean indexeddb correctly
cyrilletuzi Feb 7, 2019
9b0afe3
tests: do compilation tests on memory storage
cyrilletuzi Feb 7, 2019
d6e1812
feat: allow usage of idb when in workers
cyrilletuzi Feb 7, 2019
b392f7a
docs: changelog
cyrilletuzi Feb 7, 2019
f4427a6
fix: stringify all keys for interoperability
cyrilletuzi Feb 7, 2019
fe71c5a
docs: info about keys type
cyrilletuzi Feb 7, 2019
b1cb16d
fix: better error management
cyrilletuzi Feb 7, 2019
0a91aed
tests: better compilation tests
cyrilletuzi Feb 7, 2019
5c225fe
feat: new getItem() signature (#79)
cyrilletuzi Feb 7, 2019
585c585
merge commit
cyrilletuzi Feb 7, 2019
8e943a0
docs: migration
cyrilletuzi Feb 7, 2019
3c42132
fix: catch stringify error
cyrilletuzi Feb 7, 2019
ae9d083
fix: catch quota error on localStorage setItem
cyrilletuzi Feb 7, 2019
b3d22ae
fix: different returns in getItem to avoid any future mess
cyrilletuzi Feb 7, 2019
317e38f
fix: catch missing store error
cyrilletuzi Feb 7, 2019
e6cd950
docs: remove done todo
cyrilletuzi Feb 7, 2019
2b6f0cb
deps: Angular 8 beta 3
cyrilletuzi Feb 7, 2019
7f15fa4
release: v8.0.0-beta.3
cyrilletuzi Feb 7, 2019
5ee8f1d
fix: remove getUnsafeItem()
cyrilletuzi Feb 7, 2019
752ee45
merge commit
cyrilletuzi Feb 7, 2019
62350d4
deps: CLI v8.0.0-beta.0
cyrilletuzi Feb 8, 2019
be9cba7
docs: list of errors
cyrilletuzi Feb 8, 2019
8214441
docs: delete ignore on json schema interfaces
cyrilletuzi Feb 8, 2019
710bc38
revert: allow any in setItem()
cyrilletuzi Feb 8, 2019
8411bb5
docs
cyrilletuzi Feb 8, 2019
37117d9
docs
cyrilletuzi Feb 8, 2019
07b32be
docs
cyrilletuzi Feb 8, 2019
582aa06
docs
cyrilletuzi Feb 8, 2019
dc08109
docs
cyrilletuzi Feb 8, 2019
2032a07
docs
cyrilletuzi Feb 8, 2019
0246cfc
tests
cyrilletuzi Feb 8, 2019
6d7c5df
docs
cyrilletuzi Feb 8, 2019
6b59032
docs
cyrilletuzi Feb 8, 2019
2ee33d5
feat: new IDB storing behavior with no wrapping (#82)
cyrilletuzi Feb 11, 2019
b16e1be
fix: typing
cyrilletuzi Feb 11, 2019
62be22e
feat: new store system for interop with backward compat (#84)
cyrilletuzi Feb 13, 2019
a3e05fb
release: 8.0.0-beta.4
cyrilletuzi Feb 13, 2019
b399d82
todos
cyrilletuzi Feb 13, 2019
a3381bf
doc: info for testing types
cyrilletuzi Feb 22, 2019
8b952c8
fix: use observers in subscribe to align with RxJS 6.4 recommendations
cyrilletuzi Feb 23, 2019
b757914
merge commit
cyrilletuzi Feb 25, 2019
8df07c9
tests: move demo app in projects
cyrilletuzi Feb 25, 2019
2e4ad68
deps: update to latest betas
cyrilletuzi Feb 25, 2019
4291276
Merge branch 'master' into v8beta
cyrilletuzi Feb 26, 2019
52d0520
feat: add length alias
cyrilletuzi Mar 10, 2019
9fd39e1
fix: move to rxjs observers when error callback
cyrilletuzi Mar 10, 2019
17b0c19
Merge branch 'master' into v8beta
cyrilletuzi Mar 10, 2019
3f43eca
Merge branch 'master' into v8beta
cyrilletuzi Mar 10, 2019
08cb436
tests: e2e tests
cyrilletuzi Mar 11, 2019
6ea17a6
tests: test against v7
cyrilletuzi Mar 11, 2019
4989a38
tests
cyrilletuzi Mar 11, 2019
3dd7ec7
tests
cyrilletuzi Mar 11, 2019
2123e40
feat: allow ng7 as peerDependency
cyrilletuzi Mar 11, 2019
43d294e
docs: info about versions
cyrilletuzi Mar 11, 2019
f0dcb18
release: v8.0.0-beta.5
cyrilletuzi Mar 11, 2019
e568328
Tuple (#92)
cyrilletuzi Mar 17, 2019
63a942e
feat: removeItem when storing null or undefined (#93)
cyrilletuzi Mar 17, 2019
654d13b
docs: info about serialization (#94)
cyrilletuzi Mar 17, 2019
9a712d4
docs: v8 beta6 changelog
cyrilletuzi Mar 17, 2019
db3a269
release: v8 beta6
cyrilletuzi Mar 17, 2019
154e480
feat: ts 3.3 and last ng v8 beta
cyrilletuzi Mar 21, 2019
debd12c
doc: changelog v8 beta 7
cyrilletuzi Mar 21, 2019
10975f2
release: v8 beta 7
cyrilletuzi Mar 21, 2019
7c2dd76
test: lazy-loading
cyrilletuzi Mar 21, 2019
9f56d28
feat: last cli beta
cyrilletuzi Mar 22, 2019
33006b5
merge commit
cyrilletuzi Mar 25, 2019
0c67b9e
feat: remove xSubscribe() methods (#96)
cyrilletuzi Mar 25, 2019
af8546e
tests: remove tests concerning last pr
cyrilletuzi Mar 25, 2019
188ad02
feat: last betas, align lint to cli, ng-packagr@5
cyrilletuzi Mar 28, 2019
318e15a
tests: ci config
cyrilletuzi Mar 28, 2019
7504e54
tests: ci config
cyrilletuzi Mar 28, 2019
71b266f
tests: better e2e test
cyrilletuzi Apr 3, 2019
f7d1d43
tests: revert to core-js@2 until cli support
cyrilletuzi Apr 3, 2019
2c5db85
tests: temp fix for non interactive cli in ci
cyrilletuzi Apr 3, 2019
e633c99
tests: update webdriver for e2e tests
cyrilletuzi Apr 3, 2019
8640d05
tests: e2e test in firefox too
cyrilletuzi Apr 3, 2019
7e16f2c
feat: update to last betas
cyrilletuzi Apr 22, 2019
4dbe90f
fix: keep old TestBed API for CI
cyrilletuzi Apr 22, 2019
b1253cd
fix: go back to normal npm install in ci
cyrilletuzi Apr 22, 2019
e8b2aa9
fix: revert to ignore-scripts, cli still brokes ci
cyrilletuzi Apr 22, 2019
99c8ce8
feat: separate localStorage and Map APIs (#100)
cyrilletuzi Apr 24, 2019
534f272
fix: reintroduce xSubscribe methods but deprecated
cyrilletuzi Apr 24, 2019
b10177c
release: v8 beta8
cyrilletuzi Apr 24, 2019
1827bbf
deps: update to last betas
cyrilletuzi Apr 24, 2019
32146a0
release: v8 beta9
cyrilletuzi Apr 24, 2019
5d2ac31
doc: todos
cyrilletuzi Apr 26, 2019
03075c8
feat: Angular v8 rc0
cyrilletuzi Apr 26, 2019
3dab749
ci: back to classic config
cyrilletuzi Apr 26, 2019
7c027e1
ci: test with rxjs@6.0.0
cyrilletuzi Apr 26, 2019
0322690
ci: exact versions
cyrilletuzi Apr 26, 2019
250282c
ci: fix cli 7 version
cyrilletuzi Apr 26, 2019
3f28b72
ci: correct versions
cyrilletuzi Apr 26, 2019
c314db1
ci: remove es5 option not supported by old CLI
cyrilletuzi Apr 26, 2019
4f2cab3
feat: rxjs 6.4 as minimum
cyrilletuzi Apr 26, 2019
6a24100
release: v8 beta.10
cyrilletuzi Apr 26, 2019
578d1b8
doc: todos
cyrilletuzi Apr 26, 2019
ee35788
test: ivy (#102)
cyrilletuzi Apr 27, 2019
589a85f
feat: ng v8 rc1
cyrilletuzi Apr 27, 2019
8319278
fix: align to v8 browserslist config
cyrilletuzi Apr 27, 2019
50c251f
tests: align to v8 e2e structure
cyrilletuzi Apr 27, 2019
75dffc1
fix: align project name to CLI constraints
cyrilletuzi Apr 27, 2019
9b92065
fix: use openKeyCursor() when possible for perf
cyrilletuzi Apr 27, 2019
0616a03
feat: schema option in set()
cyrilletuzi Apr 27, 2019
bbecc17
fix: cleaner get() overloads
cyrilletuzi Apr 27, 2019
1697d38
fix: last RC
cyrilletuzi May 10, 2019
6dd2120
release: v8 beta.11
cyrilletuzi May 10, 2019
b9c38b0
feat: drop support for Angular 7, following #103
cyrilletuzi May 13, 2019
849782e
feat: Angular 8.0.0-rc.4 & ng-packagr 5.2
cyrilletuzi May 17, 2019
1dfe9aa
fix: throw when storing data that can't be serialized in localStorage…
cyrilletuzi May 17, 2019
f21e587
feat: remove deprecated platform-worker test
cyrilletuzi May 24, 2019
7bd222a
feat: Angular 8.0.0-rc.5
cyrilletuzi May 24, 2019
b3f3632
merge
cyrilletuzi May 25, 2019
2c48091
feat: engine and database info + opt-in for unwraped values in idb + …
cyrilletuzi May 26, 2019
2f91d2e
doc
cyrilletuzi May 26, 2019
efb9474
tests: aot everywhere
cyrilletuzi May 26, 2019
3405a73
fix: new interface for new options system
cyrilletuzi May 26, 2019
8ceed41
lint
cyrilletuzi May 26, 2019
6d6b16c
fix: align to cli config
cyrilletuzi May 26, 2019
a1200da
fix: remove old option from new options interface
cyrilletuzi May 27, 2019
e4854b1
revert: back to previous cli config as the new one broke TestBed test
cyrilletuzi May 27, 2019
4eb0053
fix: align to v8 TestBed.get
cyrilletuzi May 27, 2019
fc76ccd
release: v8.0.0-beta.13
cyrilletuzi May 27, 2019
51a7d3a
docs: exampleson all public API
cyrilletuzi May 27, 2019
00e420d
fix: make JSONValidator public again
cyrilletuzi May 27, 2019
63041bb
Merge branch 'master' into v8beta
cyrilletuzi May 27, 2019
274c30b
doc: reference watch PR
cyrilletuzi May 27, 2019
23c5462
doc: link to PR
cyrilletuzi May 27, 2019
ffc68b6
Merge branch 'master' into v8beta
cyrilletuzi May 27, 2019
7fb7d7a
test: ivy fix for ci
cyrilletuzi May 27, 2019
18374c0
docs: remove todos
cyrilletuzi May 27, 2019
20203bf
fix: check if data can be serialized before trying to serialiaze
cyrilletuzi May 28, 2019
9f995bd
fix: test and doc about blob refused in idb in safari private
cyrilletuzi May 28, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: engine and database info + opt-in for unwraped values in idb + …
…new options system (#107)

* feat: engine and database info + opt-in for unwraped values in idb
  • Loading branch information
cyrilletuzi authored May 26, 2019
commit 2c48091dd154e2da739f806e52252e13c0d39fdd
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ It was time to do a full review and refactoring, which results in:
- `.has()`, `.keys()` and `.size` are deprecated in `LocalStorage`. They will be removed in v9. They moved to the new `StorageMap` service.
- `JSONSchemaNumeric` deprecated (will be removed in v9)
- `LSGetItemsOptions` deprecated (not necessary anymore, will be removed in v9)
- `LOCAL_STORAGE_PREFIX` and `prefix` option of `localStorageProviders()` deprecated (will be removed in v9))
- `LOCAL_STORAGE_PREFIX` and `localStorageProviders()` deprecated (will be removed in v9). Moved to `StorageModule.forRoot()`
- `setItemSubscribe()`, `removeItemSubscribe()` and `clearSubscribe()` deprecated (will be removed in v9)

### Reduced public API
Expand Down
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Efficient client-side storage module for Angular apps and Progressive Wep Apps (
- **security**: validate data with a JSON Schema,
- **compatibility**: works around some browsers issues,
- **documentation**: API fully explained, and a changelog!
- **maintenance**: the lib follows Angular LTS and anticipates the next Angular version,
- **reference**: 1st Angular library for client-side storage according to [ngx.tools](https://ngx.tools/#/search?q=local%20storage).

## By the same author
Expand Down Expand Up @@ -52,6 +51,28 @@ npm install @ngx-pwa/local-storage@next
npm install @ngx-pwa/local-storage@6
```

*Since version 8*, this second step is:
- not required for the lib to work,
- **strongly recommended for all new applications**, as it allows interoperability
and is future-proof, as it should become the default in a future version,
- **prohibited in applications already using this lib and already deployed in production**,
as it would break with previously stored data.

```ts
import { StorageModule } from '@ngx-pwa/local-storage';

@NgModule({
imports: [
StorageModule.forRoot({
IDBNoWrap: true,
})
]
})
export class AppModule {}
```

**Must be done at initialization, ie. in `AppModule`, and must not be loaded again in another module.**

### Upgrading

If you still use the old `angular-async-local-storage` package, or to update to new versions,
Expand Down Expand Up @@ -105,7 +126,8 @@ export class YourService {
```

New *since version 8* of this lib, this service API follows the
[native `Map` API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map),
[native `Map` API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)
and the new upcoming standard [kv-storage API](https://github.com/WICG/kv-storage),
except it's asynchronous via [RxJS `Observable`s](http://reactivex.io/rxjs/).

It does the same thing as the `LocalStorage` service, but also allows more advanced operations.
Expand Down
6 changes: 3 additions & 3 deletions docs/COLLISION.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ but is not recommended as there was breaking changes in v8.
For example:

```typescript
import { localStorageProviders } from '@ngx-pwa/local-storage';
import { StorageModule } from '@ngx-pwa/local-storage';

@NgModule({
providers: [
localStorageProviders({
imports: [
StorageModule.forRoot({
IDBDBName: 'myAppStorage', // custom database name when in `indexedDB`
LSPrefix: 'myapp_', // prefix when in `localStorage` fallback
})
Expand Down
102 changes: 78 additions & 24 deletions docs/INTEROPERABILITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,42 @@ as there are important things to do and to be aware of to achieve interoperabili
Interoperability can be achieved:
- **since v8 of this lib**,
- **only for apps that haven't been deployed in production yet**,
as v8 changed the storage system to achieve interoperability:
- it won't work on data stored with this lib before v8, as it still uses the old storage system for backward compatibility,
- changing configuration on the fly would mean to **lose all previously stored data**.
as v8 uses the following opt-in option to allow interoperability:
changing configuration on the fly would mean to **lose all previously stored data**.

## Configuration
```ts
import { StorageModule } from '@ngx-pwa/local-storage';

@NgModule({
imports: [
StorageModule.forRoot({
IDBNoWrap: true,
})
]
})
export class AppModule {}
```

Note:
- it is an initialization step, so as mentioned in the examples below, **it must be done in `AppModule`**,
- **never change these options in an app already deployed in production, as all previously stored data would be lost**.

## Configuration

### `indexedDB` database and object store names

When storing in `indexedDB`, names are used for the database and the object store,
so you will need that all APIs use the same names.

Option 1: keep the config of this lib and change the names in the other APIs,
by using the default values exported by the lib:

```typescript
import { DEFAULT_IDB_DB_NAME, DEFAULT_IDB_STORE_NAME } from '@ngx-pwa/local-storage';
```

Option 2: change this lib config, according to your other APIs:
- Option 1 (recommended): change this lib config, according to your other APIs:

```typescript
import { localStorageProviders } from '@ngx-pwa/local-storage';
```ts
import { StorageModule } from '@ngx-pwa/local-storage';

@NgModule({
providers: [
localStorageProviders({
imports: [
StorageModule.forRoot({
IDBNoWrap: true,
IDBDBName: 'customDataBaseName',
IDBStoreName: 'customStoreName',
})
Expand All @@ -57,36 +63,62 @@ import { localStorageProviders } from '@ngx-pwa/local-storage';
export class AppModule {}
```

- Option 2: keep the config of this lib and change the options in the other APIs,
by using the values exported by the lib:

```ts
if (this.storageMap.backingEngine === 'indexedDB') {
const { database, store, version } = this.storageMap.backingStore;
}
```

This second option can be difficult to manage due to some browsers issues in some special contexts
(Firefox private mode and Safari cross-origin iframes),
as **the information may be wrong at initialization,**
as the storage could fallback from `indexedDB` to `localStorage`
only after a first read or write operation.

### `localStorage` prefix

In some cases (see the [browser support guide](./BROWSERS_SUPPORT)),
`indexedDB` is not available, and libs fallback to `localStorage`.
Some libs prefixes `localStorage` keys. This lib doesn't by default,
but you can add a prefix:
but you can add a prefix.

- Option 1 (recommended):

```typescript
import { localStorageProviders } from '@ngx-pwa/local-storage';
import { StorageModule } from '@ngx-pwa/local-storage';

@NgModule({
providers: [
localStorageProviders({
imports: [
StorageModule.forRoot({
LSPrefix: 'myapp_',
})
]
})
export class AppModule {}
```

- Option 2:

```ts
if (this.storageMap.backingEngine === 'localStorage') {
const { prefix } = this.storageMap.fallbackBackingStore;
}
```

### Example with `localforage`

Interoperability with `localforage` lib can be achieved with this config:

```typescript
import { localStorageProviders } from '@ngx-pwa/local-storage';
import { StorageModule } from '@ngx-pwa/local-storage';

@NgModule({
providers: [
localStorageProviders({
imports: [
StorageModule.forRoot({
IDBNoWrap: true,
LSPrefix: 'localforage/',
IDBDBName: 'localforage',
IDBStoreName: 'keyvaluepairs',
Expand All @@ -96,6 +128,28 @@ import { localStorageProviders } from '@ngx-pwa/local-storage';
export class AppModule {}
```

### Example with native `indexedDB`

Interoperability with native `indexedDB` can be achieved that way:

```ts
if (this.storageMap.backingEngine === 'indexedDB') {

const { database, store, version } = this.storageMap.backingStore;

const dbRequest = indexedDB.open(database, version);

dbRequest.addEventListener('success', () => {

const store = dbRequest.result.transaction([store], 'readonly').objectStore(store);

const request = store.get(index);

});

}
```

## Warnings

### `indexedDB` store
Expand All @@ -107,7 +161,7 @@ or when the version change (but this case doesn't happen in this lib).
**If this step is missing, then all `indexedDB` operations in the lib will fail as the store will be missing.**

Then, you need to ensure:
- you use the same database `version` as the lib (none or `1`),
- you use the same database `version` as the lib (default to `1`),
- the store is created:
- by letting this lib to be initialized first (beware of concurrency issues),
- or if another API is going first, it needs to take care of the creation of the store (with the same name).
Expand Down
19 changes: 3 additions & 16 deletions docs/MIGRATION_TO_V8.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,6 @@ npm install @ngx-pwa/local-storage@next
2. Start your project: problems will be seen at compilation.
Or you could search for `getItem` as most breaking changes are about its options.

## New `indexedDB` store

To allow interoperability, the internal `indexedDB` storing system has changed.
It is not a breaking change as the lib do it in a backward-compatible way:
- when `indexedDB` storage is empty (new app users or data swiped), the new storage is used,
- when `indexedDB` old storage is here, the lib stays on this one.

So it should not concern you, but as it is very sensitive change, we recommend
**to test previously stored data is not lost before deploying in production**.

It's internal stuff, but it also means there is a transition phase where some of the users of your app
will be on the new storage, and others will be on the old one.

## The bad part: breaking changes

**The following changes may require action from you**.
Expand Down Expand Up @@ -343,11 +330,11 @@ export class AppModule {}

Since v8:
```typescript
import { localStorageProviders } from '@ngx-pwa/local-storage';
import { StorageModule } from '@ngx-pwa/local-storage';

@NgModule({
providers: [
localStorageProviders({
imports: [
StorageModule.forRoot({
LSPrefix: 'myapp_', // Note the underscore
IDBDBName: 'myapp_ngStorage',
}),
Expand Down
11 changes: 6 additions & 5 deletions projects/demo/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { StorageModule } from '@ngx-pwa/local-storage';

import { AppComponent } from './app.component';

@NgModule({
declarations: [
AppComponent
],
declarations: [AppComponent],
imports: [
BrowserModule
BrowserModule,
StorageModule.forRoot({
IDBNoWrap: true,
}),
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
5 changes: 2 additions & 3 deletions projects/ivy/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';

// TODO: reintroduce `StorageModule.forRoot()`
@NgModule({
declarations: [
AppComponent
],
declarations: [AppComponent],
imports: [
BrowserModule
],
Expand Down
9 changes: 4 additions & 5 deletions projects/localforage/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { localStorageProviders } from '@ngx-pwa/local-storage';
import { StorageModule } from '@ngx-pwa/local-storage';

import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
Expand All @@ -14,13 +14,12 @@ import { HomeComponent } from './home/home.component';
imports: [
BrowserModule,
AppRoutingModule,
],
providers: [
localStorageProviders({
StorageModule.forRoot({
LSPrefix: 'localforage/',
IDBNoWrap: true,
IDBDBName: 'localforage',
IDBStoreName: 'keyvaluepairs'
})
}),
],
bootstrap: [AppComponent]
})
Expand Down
Loading