Skip to content

Commit 12669a0

Browse files
author
Krzysztof Borowy
authored
v2 improvements - web (#284)
* chore: add example web * feat: idb for web storage, better example * test: unit tests for web storage * docs: content change
1 parent 60adfbe commit 12669a0

35 files changed

+9847
-230
lines changed

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
11
# Async Storage
22

3-
A collection of persistent data storages, unified into a single API.
3+
A collection of persistent data storages, targeting different platforms, unified within a single API.
44

55
## Work in progress
66

77
Async Storage v2 is under development.
88

9-
If you're looking for published and operational Async Storage version, please check out [`LEGACY`](https://github.com/react-native-community/async-storage/tree/LEGACY) branch.
9+
If you're looking for published and operational Async Storage version, please check out [`LEGACY`](https://github.com/react-native-community/async-storage/tree/LEGACY) branch.
1010

1111
## Features
1212

13-
- Unified API to consume any supported storage
14-
- Different type of storage for different purpose, see [available storages](#available-storages)
15-
- Extensible functionality, to leverage full storage potential
16-
- Support for Mobile, Web and more
13+
- One, unified API to support different storages
14+
- [Extensible functionality](./packages/core/docs/API.md#extensions)
15+
- Targets Mobile, Web and more
16+
1717

1818
## Getting started
1919

2020
### Install
2121

22-
1. Get required core
22+
1. Install Core dependency
2323

2424
```bash
2525
yarn add @react-native-community/async-storage@next
2626
```
2727

28-
2. Pick desired [storage for your platform.](#available-storages)
28+
2. Select a [storage for your platform.](#available-storages)
2929

3030

3131
### Usage
3232

33-
Example usage can [be found here.](./packages/core/docs/Usage.md)
33+
See usage can [be found here.](./packages/core/docs/Usage.md)
3434

3535

3636
## Available storages
3737

38-
- [Legacy](./packages/storage-legacy/README.md) - for React Native
39-
- [Web](./packages/storage-web/README.md) - for Web applications
38+
- [Legacy](./packages/storage-legacy/README.md) - for React Native apps
39+
- [Web](./packages/storage-web/README.md) - for Web apps
4040

4141

4242
## Documentation

examples/mobile/README.md

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
# Async Storage mobile examples
1+
# Async Storage - Mobile example
22

3-
## Running the example
3+
Example React Native app presenting features of [`async-storage-backend-legacy`](https://github.com/react-native-community/async-storage/tree/master/packages/storage-legacy).
44

5-
1. Get dependencies
5+
## Running the app
6+
7+
1. Install dependencies
68

79
```bash
810
$ yarn install
911
```
1012

11-
2. Install the app
13+
2. Run the app on either platform
1214

1315
```bash
1416
# Android
@@ -18,17 +20,10 @@ $ yarn start:android
1820
$ yarn start:ios
1921
```
2022

21-
3. Run packager
22-
23-
```bash
24-
$ yarn start
25-
```
26-
2723
## Feedback
2824

29-
Let me know about any issue found or feedback you have at [Async-Storage issue page](https://github.com/react-native-community/async-storage/issues).
30-
Please mark it as `examples` label.
25+
All feedback is welcome at [Async-Storage issue page](https://github.com/react-native-community/async-storage/issues).
3126

3227
## License
3328

34-
MIT
29+
MIT.

examples/mobile/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ DEPENDENCIES:
111111
- yoga (from `../node_modules/react-native/ReactCommon/yoga`)
112112

113113
SPEC REPOS:
114-
https://github.com/cocoapods/specs.git:
114+
https://github.com/CocoaPods/Specs.git:
115115
- boost-for-react-native
116116

117117
EXTERNAL SOURCES:
@@ -190,4 +190,4 @@ SPEC CHECKSUMS:
190190

191191
PODFILE CHECKSUM: 4e647e55207a6e7a83f354d0cfc8a32c14b6e9ae
192192

193-
COCOAPODS: 1.7.1
193+
COCOAPODS: 1.8.4

examples/mobile/package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"name": "asyncstorageexample",
2+
"name": "AsyncStorageMobileExample",
33
"version": "0.0.1",
44
"private": true,
55
"scripts": {
66
"start": "react-native start",
7-
"start:android": "react-native run-android",
8-
"start:ios": "react-native run-ios",
7+
"android": "react-native run-android",
8+
"ios": "react-native run-ios",
99
"test": "jest",
1010
"lint": "eslint ."
1111
},
@@ -17,11 +17,10 @@
1717
"devDependencies": {
1818
"@babel/core": "7.5.4",
1919
"@babel/runtime": "7.5.4",
20-
"@react-native-community/eslint-config": "0.0.3",
20+
"@react-native-community/eslint-config": "0.0.5",
2121
"babel-jest": "24.8.0",
2222
"babel-plugin-module-resolver": "^3.2.0",
2323
"eslint": "5.16.0",
24-
"get-yarn-workspaces": "^1.0.2",
2524
"jest": "24.8.0",
2625
"metro-react-native-babel-preset": "0.55.0",
2726
"react-test-renderer": "16.8.6"

examples/mobile/src/legacy/storage.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import LegacyStorage from '@react-native-community/async-storage-backend-legacy';
22
import AsyncStorageFactory from '@react-native-community/async-storage';
33

4-
54
const legacy = new LegacyStorage();
65

7-
const storage = AsyncStorageFactory.create(legacy, {});
6+
const storage = AsyncStorageFactory.create(legacy);
87

98
export default storage;

examples/mobile/yarn.lock

Lines changed: 73 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -910,11 +910,13 @@
910910
shell-quote "1.6.1"
911911
ws "^1.1.0"
912912

913-
"@react-native-community/eslint-config@0.0.3":
914-
version "0.0.3"
915-
resolved "https://registry.yarnpkg.com/@react-native-community/eslint-config/-/eslint-config-0.0.3.tgz#bf9be8434caa18f85b570cf4e28366f2a7f1ea91"
916-
integrity sha512-YmCiqoiqgSW8YpWYWLwG4WYwVIwvkhfH97COxbin71CuCr5muZPlmhHOFwo2gIQzUvt1ewFb1shtUi1X8TAVhA==
913+
"@react-native-community/eslint-config@0.0.5":
914+
version "0.0.5"
915+
resolved "https://registry.yarnpkg.com/@react-native-community/eslint-config/-/eslint-config-0.0.5.tgz#584f6493258202a57efc22e7be66966e43832795"
916+
integrity sha512-jwO2tnKaTPTLX5XYXMHGEnFdf543SU7jz98/OF5mDH3b7lP+BOaCD+jVfqqHoDRkcqyPlYiR1CgwVGWpi0vMWg==
917917
dependencies:
918+
"@typescript-eslint/eslint-plugin" "^1.5.0"
919+
"@typescript-eslint/parser" "^1.5.0"
918920
babel-eslint "10.0.1"
919921
eslint-plugin-eslint-comments "^3.1.1"
920922
eslint-plugin-flowtype "2.50.3"
@@ -958,6 +960,11 @@
958960
dependencies:
959961
"@babel/types" "^7.3.0"
960962

963+
"@types/eslint-visitor-keys@^1.0.0":
964+
version "1.0.0"
965+
resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d"
966+
integrity sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag==
967+
961968
"@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0":
962969
version "2.0.1"
963970
resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.1.tgz#42995b446db9a48a11a07ec083499a860e9138ff"
@@ -978,6 +985,11 @@
978985
"@types/istanbul-lib-coverage" "*"
979986
"@types/istanbul-lib-report" "*"
980987

988+
"@types/json-schema@^7.0.3":
989+
version "7.0.4"
990+
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.4.tgz#38fd73ddfd9b55abb1e1b2ed578cb55bd7b7d339"
991+
integrity sha512-8+KAKzEvSUdeo+kmqnKrqgeE+LcA0tjYWFY7RPProVYwnqDjukzO+3b6dLD56rYX5TdWejnEOLJYOIeh4CXKuA==
992+
981993
"@types/stack-utils@^1.0.1":
982994
version "1.0.1"
983995
resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e"
@@ -988,6 +1000,44 @@
9881000
resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-12.0.12.tgz#45dd1d0638e8c8f153e87d296907659296873916"
9891001
integrity sha512-SOhuU4wNBxhhTHxYaiG5NY4HBhDIDnJF60GU+2LqHAdKKer86//e4yg69aENCtQ04n0ovz+tq2YPME5t5yp4pw==
9901002

1003+
"@typescript-eslint/eslint-plugin@^1.5.0":
1004+
version "1.13.0"
1005+
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-1.13.0.tgz#22fed9b16ddfeb402fd7bcde56307820f6ebc49f"
1006+
integrity sha512-WQHCozMnuNADiqMtsNzp96FNox5sOVpU8Xt4meaT4em8lOG1SrOv92/mUbEHQVh90sldKSfcOc/I0FOb/14G1g==
1007+
dependencies:
1008+
"@typescript-eslint/experimental-utils" "1.13.0"
1009+
eslint-utils "^1.3.1"
1010+
functional-red-black-tree "^1.0.1"
1011+
regexpp "^2.0.1"
1012+
tsutils "^3.7.0"
1013+
1014+
"@typescript-eslint/experimental-utils@1.13.0":
1015+
version "1.13.0"
1016+
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-1.13.0.tgz#b08c60d780c0067de2fb44b04b432f540138301e"
1017+
integrity sha512-zmpS6SyqG4ZF64ffaJ6uah6tWWWgZ8m+c54XXgwFtUv0jNz8aJAVx8chMCvnk7yl6xwn8d+d96+tWp7fXzTuDg==
1018+
dependencies:
1019+
"@types/json-schema" "^7.0.3"
1020+
"@typescript-eslint/typescript-estree" "1.13.0"
1021+
eslint-scope "^4.0.0"
1022+
1023+
"@typescript-eslint/parser@^1.5.0":
1024+
version "1.13.0"
1025+
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-1.13.0.tgz#61ac7811ea52791c47dc9fd4dd4a184fae9ac355"
1026+
integrity sha512-ITMBs52PCPgLb2nGPoeT4iU3HdQZHcPaZVw+7CsFagRJHUhyeTgorEwHXhFf3e7Evzi8oujKNpHc8TONth8AdQ==
1027+
dependencies:
1028+
"@types/eslint-visitor-keys" "^1.0.0"
1029+
"@typescript-eslint/experimental-utils" "1.13.0"
1030+
"@typescript-eslint/typescript-estree" "1.13.0"
1031+
eslint-visitor-keys "^1.0.0"
1032+
1033+
"@typescript-eslint/typescript-estree@1.13.0":
1034+
version "1.13.0"
1035+
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-1.13.0.tgz#8140f17d0f60c03619798f1d628b8434913dc32e"
1036+
integrity sha512-b5rCmd2e6DCC6tCTN9GSUAuxdYwCM/k/2wdjHGrIRGPSJotWMCe/dGpi66u42bhuh8q3QBzqM4TMA1GUUCJvdw==
1037+
dependencies:
1038+
lodash.unescape "4.0.1"
1039+
semver "5.5.0"
1040+
9911041
abab@^2.0.0:
9921042
version "2.0.0"
9931043
resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.0.tgz#aba0ab4c5eee2d4c79d3487d85450fb2376ebb0f"
@@ -2172,7 +2222,7 @@ eslint-scope@3.7.1:
21722222
esrecurse "^4.1.0"
21732223
estraverse "^4.1.1"
21742224

2175-
eslint-scope@^4.0.3:
2225+
eslint-scope@^4.0.0, eslint-scope@^4.0.3:
21762226
version "4.0.3"
21772227
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.3.tgz#ca03833310f6889a3264781aa82e63eb9cfe7848"
21782228
integrity sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg==
@@ -2559,11 +2609,6 @@ find-cache-dir@^2.0.0:
25592609
make-dir "^2.0.0"
25602610
pkg-dir "^3.0.0"
25612611

2562-
find-root@^1.1.0:
2563-
version "1.1.0"
2564-
resolved "https://registry.yarnpkg.com/find-root/-/find-root-1.1.0.tgz#abcfc8ba76f708c42a97b3d685b7e9450bfb9ce4"
2565-
integrity sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==
2566-
25672612
find-up@^2.0.0, find-up@^2.1.0:
25682613
version "2.1.0"
25692614
resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7"
@@ -2592,11 +2637,6 @@ flatted@^2.0.0:
25922637
resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.1.tgz#69e57caa8f0eacbc281d2e2cb458d46fdb449e08"
25932638
integrity sha512-a1hQMktqW9Nmqr5aktAux3JMNqaucxGcjtjWnZLHX7yyPCmlSV3M54nGYbqT8K+0GhF3NBgmJCc3ma+WOgX8Jg==
25942639

2595-
flatten@^1.0.2:
2596-
version "1.0.2"
2597-
resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782"
2598-
integrity sha1-2uRqnXj74lKSJYzB54CkHZXAN4I=
2599-
26002640
for-in@^1.0.2:
26012641
version "1.0.2"
26022642
resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"
@@ -2712,15 +2752,6 @@ get-value@^2.0.3, get-value@^2.0.6:
27122752
resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28"
27132753
integrity sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=
27142754

2715-
get-yarn-workspaces@^1.0.2:
2716-
version "1.0.2"
2717-
resolved "https://registry.yarnpkg.com/get-yarn-workspaces/-/get-yarn-workspaces-1.0.2.tgz#81591bdb392f1c6bac09cdc8491a6d275781aa44"
2718-
integrity sha512-Auel048Uclfgr74oNXKZWH30UgKDZXQdfUfgD9iWXdoUGJpeWg9lSuX/FZkQ6RB3KnBfAaf70xQXfwOjiE9rPw==
2719-
dependencies:
2720-
find-root "^1.1.0"
2721-
flatten "^1.0.2"
2722-
glob "^7.1.2"
2723-
27242755
getpass@^0.1.1:
27252756
version "0.1.7"
27262757
resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa"
@@ -3881,6 +3912,11 @@ lodash.throttle@^4.1.1:
38813912
resolved "https://registry.yarnpkg.com/lodash.throttle/-/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4"
38823913
integrity sha1-wj6RtxAkKscMN/HhzaknTMOb8vQ=
38833914

3915+
lodash.unescape@4.0.1:
3916+
version "4.0.1"
3917+
resolved "https://registry.yarnpkg.com/lodash.unescape/-/lodash.unescape-4.0.1.tgz#bf2249886ce514cda112fae9218cdc065211fc9c"
3918+
integrity sha1-vyJJiGzlFM2hEvrpIYzcBlIR/Jw=
3919+
38843920
lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.5, lodash@^4.3.0, lodash@^4.6.1:
38853921
version "4.17.14"
38863922
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.14.tgz#9ce487ae66c96254fe20b599f21b6816028078ba"
@@ -5526,6 +5562,11 @@ scheduler@^0.13.6:
55265562
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.0.tgz#790a7cf6fea5459bac96110b29b60412dc8ff96b"
55275563
integrity sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==
55285564

5565+
semver@5.5.0:
5566+
version "5.5.0"
5567+
resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab"
5568+
integrity sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==
5569+
55295570
semver@^6.0.0:
55305571
version "6.2.0"
55315572
resolved "https://registry.yarnpkg.com/semver/-/semver-6.2.0.tgz#4d813d9590aaf8a9192693d6c85b9344de5901db"
@@ -6052,11 +6093,18 @@ trim-right@^1.0.1:
60526093
resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003"
60536094
integrity sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=
60546095

6055-
tslib@^1.9.0:
6096+
tslib@^1.8.1, tslib@^1.9.0:
60566097
version "1.10.0"
60576098
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a"
60586099
integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==
60596100

6101+
tsutils@^3.7.0:
6102+
version "3.17.1"
6103+
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.17.1.tgz#ed719917f11ca0dee586272b2ac49e015a2dd759"
6104+
integrity sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g==
6105+
dependencies:
6106+
tslib "^1.8.1"
6107+
60606108
tunnel-agent@^0.6.0:
60616109
version "0.6.0"
60626110
resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd"

examples/web/.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*

examples/web/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Async Storage - Web example
2+
3+
Example React app presenting features of [`async-storage-backend-web`](https://github.com/react-native-community/async-storage/tree/master/packages/storage-web).
4+
5+
## Running the app
6+
7+
1. Install dependencies
8+
9+
```bash
10+
$ yarn install
11+
```
12+
13+
2. Run the app
14+
15+
```bash
16+
$ yarn start
17+
```
18+
19+
## Feedback
20+
21+
All feedback is welcome at [Async-Storage issue page](https://github.com/react-native-community/async-storage/issues).
22+
23+
## License
24+
25+
MIT.

0 commit comments

Comments
 (0)