@@ -29,13 +29,7 @@ npm install @ngx-pwa/local-storage@next
29
29
2 . Start your project: problems will be seen at compilation.
30
30
Or you could search for ` getItem ` as most breaking changes are about its options.
31
31
32
- ## The bad part: breaking changes
33
-
34
- ** The following changes may require action from you** .
35
-
36
- The main change is to add ` type ` to all your JSON schemas.
37
-
38
- ### New ` indexedDB ` store
32
+ ## New ` indexedDB ` store
39
33
40
34
To allow interoperability, the internal ` indexedDB ` storing system has changed.
41
35
It is not a breaking change as the lib do it in a backward-compatible way:
@@ -48,6 +42,12 @@ So it should not concern you, but as it is very sensitive change, we recommend
48
42
It's internal stuff, but it also means there is a transition phase where some of the users of your app
49
43
will be on the new storage, and others will be on the old one.
50
44
45
+ ## The bad part: breaking changes
46
+
47
+ ** The following changes may require action from you** .
48
+
49
+ The main change is to add ` type ` to all your JSON schemas.
50
+
51
51
### Validation of arrays
52
52
53
53
** ` type ` option is now required.**
@@ -126,55 +126,31 @@ It also means enums of different types are no longer possible (and it's better f
126
126
127
127
Also, ` JSONSchemaEnum ` interface is removed.
128
128
129
+ ### ` JSONSchemaNull ` removed
130
+
131
+ ` JSONSchemaNull ` is removed (it was useless, as if the data is ` null ` , validation doesn't occur).
132
+
129
133
### Additional properties in schemas
130
134
131
135
The ` schema ` option of ` getItem() ` now only accepts our own ` JSONSchema ` interface,
132
136
which is a subset of the JSON Schema standard.
133
137
134
138
This lib has always discarded some features of the standard, as it uses the schemas for a specific purpose (validation).
135
- But before v8, extra properties in the schema were accepted even if not supported. It is no longer possible since v8.
139
+ But before v8, extra properties in the schema were accepted even if not supported.
140
+ It is no longer possible since v8 due to TypeScript limitations.
136
141
137
142
While not recommended, you can still force it:
138
143
``` typescript
139
144
this .localStorage .getItem (' test' , schema as any )
140
145
```
141
146
142
- ### Prefix and collision
143
-
144
- If you were using a prefix because you have multiple apps on the same subdomain,
145
- configuration has changed to allow interoperability.
146
- The old one still works for now but is deprecated and will be removed in v9.
147
-
148
- Before v8:
149
- ``` typescript
150
- import { localStorageProviders , LOCAL_STORAGE_PREFIX } from ' @ngx-pwa/local-storage' ;
151
-
152
- @NgModule ({
153
- providers: [
154
- localStorageProviders ({ prefix: ' myapp' }),
155
- // or
156
- { provide: LOCAL_STORAGE_PREFIX , useValue: ' myapp' },
157
- ]
158
- })
159
- export class AppModule {}
160
- ```
161
-
162
- Since v8:
163
- ``` typescript
164
- import { localStorageProviders } from ' @ngx-pwa/local-storage' ;
147
+ ### ` xSubscribe() ` methods removed
165
148
166
- @NgModule ({
167
- providers: [
168
- localStorageProviders ({
169
- LSPrefix: ' myapp_' , // Note the underscore
170
- IDBDBName: ' myapp_ngStorage' ,
171
- }),
172
- ]
173
- })
174
- export class AppModule {}
175
- ```
149
+ Auto-subscription methods were added for simplicity, but they were risky shortcuts because:
150
+ - potential errors are not managed,
151
+ - it can cause concurrency issues, especially given the average RxJS knowledge.
176
152
177
- ** Be very careful while changing this, as an error could mean the loss of all previously stored data. **
153
+ So ` setItemSubscribe() ` , ` removeItemSubscribe() ` and ` clearSubscribe() ` are removed: subscribe manually.
178
154
179
155
## The good part: simplication changes
180
156
@@ -222,16 +198,56 @@ this.localStorage.getItem('test', { type: 'string' }).subscribe((data) => {
222
198
223
199
Cast is still needed for objects. Follow the new [ validation guide] ( ./VALIDATION.md ) .
224
200
201
+ ## Deprecations
202
+
203
+ Version 8 is a fresh new start, where everything has been cleaned. But as the previous changes already require quite some work,
204
+ ** the following features still work in v8 but are deprecated** . They will be removed in v9.
205
+ So there's no hurry, but as soon as you have some time, do the following changes too.
206
+
225
207
### Use the generic ` JSONSchema `
226
208
227
209
Now the ` JSONSchema ` interface has been refactored, just use this one.
228
210
IntelliSense will adjust itself based on the ` type ` option.
229
211
The specific interfaces (` JSONSchemaString ` , ` JSONSchemaBoolean ` and so on) are still there but are useless.
230
212
231
213
` JSONSchemaNumeric ` still works but is deprecated in favor of ` JSONSchemaNumber ` or ` JSONSchemaInteger `
232
- (but again, just use ` JSONSchema ` ). Will be removed in v9.
214
+ (but again, just use ` JSONSchema ` ).
215
+
216
+ ### Prefix and collision
217
+
218
+ If you were using a prefix because you have multiple apps on the same subdomain,
219
+ configuration has changed to allow interoperability.
220
+
221
+ Before v8:
222
+ ``` typescript
223
+ import { localStorageProviders , LOCAL_STORAGE_PREFIX } from ' @ngx-pwa/local-storage' ;
224
+
225
+ @NgModule ({
226
+ providers: [
227
+ localStorageProviders ({ prefix: ' myapp' }),
228
+ // or
229
+ { provide: LOCAL_STORAGE_PREFIX , useValue: ' myapp' },
230
+ ]
231
+ })
232
+ export class AppModule {}
233
+ ```
233
234
234
- Also, ` JSONSchemaNull ` is removed (it was useless, as if the data is ` null ` , validation doesn't occur).
235
+ Since v8:
236
+ ``` typescript
237
+ import { localStorageProviders } from ' @ngx-pwa/local-storage' ;
238
+
239
+ @NgModule ({
240
+ providers: [
241
+ localStorageProviders ({
242
+ LSPrefix: ' myapp_' , // Note the underscore
243
+ IDBDBName: ' myapp_ngStorage' ,
244
+ }),
245
+ ]
246
+ })
247
+ export class AppModule {}
248
+ ```
249
+
250
+ ** Be very careful while changing this, as an error could mean the loss of all previously stored data.**
235
251
236
252
## More documentation
237
253
0 commit comments