@@ -30,7 +30,6 @@ static getItem(key: string, [callback]: ?(error: ?Error, result: ?string) => voi
30
30
**Example**:
31
31
32
32
` ` ` js
33
-
34
33
getMyStringValue = async () => {
35
34
try {
36
35
return await AsyncStorage .getItem (' @key' )
@@ -39,12 +38,10 @@ getMyStringValue = async () => {
39
38
}
40
39
41
40
console .log (' Done.' )
42
-
43
41
}
44
42
` ` `
45
43
46
44
` ` ` js
47
-
48
45
getMyObject = async () => {
49
46
try {
50
47
const jsonValue = await AsyncStorage .getItem (' @key' )
@@ -54,7 +51,6 @@ getMyObject = async () => {
54
51
}
55
52
56
53
console .log (' Done.' )
57
-
58
54
}
59
55
` ` `
60
56
@@ -66,7 +62,7 @@ getMyObject = async () => {
66
62
67
63
## ` setItem `
68
64
69
- Sets a string ` value ` for given ` key ` . This operation can either modify an existing entry, if it did exist for given ` key ` , or add new one otherwise.
65
+ Sets a string ` value ` for given ` key ` . This operation can either modify an existing entry, if it did exist for given ` key ` , or add new one otherwise.
70
66
71
67
In order to store object value, you need to serialize it, e.g. using ` JSON .stringify ()` .
72
68
@@ -87,7 +83,6 @@ static setItem(key: string, value: string, [callback]: ?(error: ?Error) => void)
87
83
**Example**:
88
84
89
85
` ` ` js
90
-
91
86
setStringValue = async (value ) => {
92
87
try {
93
88
await AsyncStorage .setItem (' key' , value)
@@ -100,7 +95,6 @@ setStringValue = async (value) => {
100
95
` ` `
101
96
102
97
` ` ` js
103
-
104
98
setObjectValue = async (value ) => {
105
99
try {
106
100
const jsonValue = JSON .stringify (value)
@@ -121,7 +115,6 @@ setObjectValue = async (value) => {
121
115
## ` mergeItem `
122
116
123
117
Merges an existing value stored under ` key ` , with new ` value ` , assuming both values are **stringified JSON**.
124
- **NOTE**: This is not supported by all native implementations.
125
118
126
119
**Signature**:
127
120
@@ -180,7 +173,6 @@ mergeUsers = async () => {
180
173
// }
181
174
}
182
175
}
183
-
184
176
` ` `
185
177
186
178
<br />
@@ -242,7 +234,6 @@ static getAllKeys([callback]: ?(error: ?Error, keys: ?Array<string>) => void): P
242
234
**Example**:
243
235
244
236
` ` ` js
245
-
246
237
getAllKeys = async () => {
247
238
let keys = []
248
239
try {
@@ -255,7 +246,6 @@ getAllKeys = async () => {
255
246
// example console.log result:
256
247
// ['@MyApp_user', '@MyApp_key']
257
248
}
258
-
259
249
` ` `
260
250
261
251
<br />
@@ -281,7 +271,6 @@ static multiGet(keys: Array<string>, [callback]: ?(errors: ?Array<Error>, result
281
271
**Example**:
282
272
283
273
` ` ` js
284
-
285
274
getMultiple = async () => {
286
275
287
276
let values
@@ -295,7 +284,6 @@ getMultiple = async () => {
295
284
// example console.log output:
296
285
// [ ['@MyApp_user', 'myUserValue'], ['@MyApp_key', 'myKeyValue'] ]
297
286
}
298
-
299
287
` ` `
300
288
301
289
<br />
@@ -321,7 +309,6 @@ static multiSet(keyValuePairs: Array<Array<string>>, [callback]: ?(errors: ?Arra
321
309
**Example**:
322
310
323
311
` ` ` js
324
-
325
312
multiSet = async () => {
326
313
const firstPair = [" @MyApp_user" , " value_1" ]
327
314
const secondPair = [" @MyApp_key" , " value_2" ]
@@ -333,7 +320,6 @@ multiSet = async () => {
333
320
334
321
console .log (" Done." )
335
322
}
336
-
337
323
` ` `
338
324
339
325
<br />
@@ -344,7 +330,6 @@ multiSet = async () => {
344
330
## ` multiMerge `
345
331
346
332
Multiple merging of existing and new values in a batch. Assumes that values are *stringified JSON*. Once completed, invokes ` callback ` with errors (if any).
347
- **NOTE**: This is not supported by all native implementations.
348
333
349
334
**Signature**:
350
335
@@ -430,7 +415,6 @@ mergeMultiple = async () => {
430
415
// ]
431
416
// ]
432
417
}
433
-
434
418
` ` `
435
419
436
420
@@ -501,7 +485,6 @@ clearAll = async () => {
501
485
502
486
console .log (' Done.' )
503
487
}
504
-
505
488
` ` `
506
489
507
490
<!-- ------------------------ HOOKS ------------------------ -->
0 commit comments