Skip to content

Commit 11057fc

Browse files
author
Krzysztof
authored
Docs: Async Storage website (#369)
* docs: initial website
1 parent 633cff0 commit 11057fc

33 files changed

+10214
-255
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Website Deployment
2+
on:
3+
push:
4+
branches:
5+
- master
6+
paths:
7+
- 'website/**'
8+
9+
jobs:
10+
deploy:
11+
name: Deploy website
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: Cache/restore dependencies
17+
uses: actions/cache@v1
18+
id: cache
19+
with:
20+
path: ./website/node_modules
21+
key: website-${{ hashFiles('website/yarn.lock') }}
22+
- name: Install dependencies
23+
if: steps.cache.outputs.cache-hit != 'true'
24+
run: yarn install --frozen-lockfile --cwd ./website
25+
- name: Add ssh keys
26+
env:
27+
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
28+
run: |
29+
mkdir -p ~/.ssh
30+
ssh-keyscan github.com >> ~/.ssh/known_hosts
31+
echo "${{ secrets.GH_PAGES_DEPLOY }}" > ~/.ssh/id_rsa
32+
chmod 600 ~/.ssh/id_rsa
33+
cat <<EOT >> ~/.ssh/config
34+
Host github.com
35+
HostName github.com
36+
IdentityFile ~/.ssh/id_rsa
37+
EOT
38+
- name: Release
39+
working-directory: ./website
40+
env:
41+
USE_SSH: true
42+
GIT_USER: git
43+
run: |
44+
git config --global user.email "[email protected]"
45+
git config --global user.name "gh-actions"
46+
yarn deploy
47+
48+
49+

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,4 @@ docs
7676
.idea
7777
bin/test.js
7878
codorials
79+
website/

README.md

Lines changed: 4 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -14,131 +14,14 @@ An asynchronous, unencrypted, persistent, key-value storage system for React Nat
1414

1515
## Getting Started
1616

17+
Head over to [documentation](https://react-native-community.github.io/async-storage/) to learn more.
1718

18-
### Install
19-
20-
```
21-
$ yarn add @react-native-community/async-storage
22-
```
23-
24-
### Link
25-
26-
- **React Native 0.60+**
27-
28-
[CLI autolink feature](https://github.com/react-native-community/cli/blob/master/docs/autolinking.md) links the module while building the app.
29-
30-
Use CocoaPods to add the native `RNAsyncStorage` to your project:
31-
32-
```bash
33-
$ npx pod-install
34-
```
35-
36-
- **React Native <= 0.59**
37-
38-
39-
```bash
40-
$ react-native link @react-native-community/async-storage
41-
```
42-
43-
*Note:* For `macOS` and `Windows` the [manual linking](docs/Linking.md) is currently the only linking option.
44-
45-
46-
See docs for [manual linking guide.](docs/Linking.md)
47-
48-
### **Upgrading to React Native *0.60+***
49-
50-
React Native 0.60+ comes with `autolinking` feature, which automatically links Native Modules in your project.
51-
In order to get it to work, make sure you `unlink` `Async Storage` first (if you had linked it before):
52-
53-
```bash
54-
$ react-native unlink @react-native-community/async-storage
55-
```
56-
57-
58-
## Usage
59-
60-
AsyncStorage can only store `string` data, so in order to store object data you need to serialize it first.
61-
For data that can be serialized to JSON you can use `JSON.stringify()` when saving the data and `JSON.parse()` when loading the data.
62-
63-
64-
### Importing
65-
66-
```js
67-
import AsyncStorage from '@react-native-community/async-storage';
68-
```
69-
70-
### Storing data
71-
72-
`setItem()` is used both to add new data item (when no data for given key exists), and to modify exiting item (when previous data for given key exists).
73-
74-
#### Storing string value
75-
```jsx
76-
const storeData = async (value) => {
77-
try {
78-
await AsyncStorage.setItem('@storage_Key', value)
79-
} catch (e) {
80-
// saving error
81-
}
82-
}
83-
```
84-
85-
#### Storing object value
86-
```jsx
87-
const storeData = async (value) => {
88-
try {
89-
const jsonValue = JSON.stringify(value)
90-
await AsyncStorage.setItem('@storage_Key', jsonValue)
91-
} catch (e) {
92-
// saving error
93-
}
94-
}
95-
```
96-
97-
### Reading data
98-
99-
`getItem` returns a promise that either resolves to stored value when data is found for given key, or returns `null` otherwise.
100-
101-
#### Reading string value
102-
```jsx
103-
104-
getData = async () => {
105-
try {
106-
const value = await AsyncStorage.getItem('@storage_Key')
107-
if(value !== null) {
108-
// value previously stored
109-
}
110-
} catch(e) {
111-
// error reading value
112-
}
113-
}
114-
115-
```
116-
#### Reading object value
117-
118-
```jsx
119-
120-
getData = async () => {
121-
try {
122-
const jsonValue = await AsyncStorage.getItem('@storage_Key')
123-
return jsonValue != null ? JSON.parse(jsonValue) : null;
124-
} catch(e) {
125-
// error reading value
126-
}
127-
}
128-
129-
```
130-
131-
## Advanced usage
132-
See docs for [API and more examples](docs/API.md) or [advanced usages](docs/advanced).
133-
134-
## Writing tests
135-
136-
Using [Jest](https://jestjs.io/) for testing? Make sure to check out [docs on how to integrate it with this module.](./docs/Jest-integration.md)
13719

13820
## Contribution
21+
Pull requests are welcome. Please open an issue first to discuss what you would like to change.
13922

140-
See the [CONTRIBUTING](CONTRIBUTING.md) file for how to help out.
23+
See the [CONTRIBUTING](CONTRIBUTING.md) file for more information.
14124

14225
## License
14326

144-
MIT
27+
MIT.

docs/advanced/DedicatedExecutor.md

Lines changed: 0 additions & 22 deletions
This file was deleted.

website/.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Dependencies
2+
/node_modules
3+
4+
# Production
5+
/build
6+
7+
# Generated files
8+
.docusaurus
9+
.cache-loader
10+
11+
# Misc
12+
.DS_Store
13+
.env.local
14+
.env.development.local
15+
.env.test.local
16+
.env.production.local
17+
18+
npm-debug.log*
19+
yarn-debug.log*
20+
yarn-error.log*

website/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Async Storage website
2+
3+
Built using [Docusaurus 2](https://v2.docusaurus.io/).
4+
5+
6+
## Development
7+
8+
### Installation
9+
10+
```
11+
$ yarn
12+
```
13+
14+
### Run locally
15+
16+
```
17+
$ yarn start
18+
```
19+
20+
This command starts a local development server and open up a browser window. Most changes are reflected live without having to restart the server.

docs/API.md renamed to website/docs/API.md

Lines changed: 5 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,10 @@
1-
# Async Storage API with examples.
1+
---
2+
id: api
3+
title: API
4+
sidebar_label: API
5+
---
26

37

4-
5-
**Table of Contents**
6-
- [getItem](#getItem)
7-
- [setItem](#setItem)
8-
- [mergeItem](#mergeItem)
9-
- [removeItem](#removeItem)
10-
- [getAllKeys](#getAllKeys)
11-
- [multiGet](#multiGet)
12-
- [multiSet](#multiSet)
13-
- [multiMerge](#multiMerge)
14-
- [multiRemove](#multiRemove)
15-
- [clear](#clear)
16-
- [flushGetRequests](#flushGetRequests)
17-
- [useAsyncStorage](#useAsyncStorage)
18-
19-
<br />
20-
218
<!-- ------------------------ GET ITEM ------------------------ -->
229

2310
## `getItem`
@@ -516,29 +503,6 @@ clearAll = async () => {
516503

517504
```
518505
519-
520-
<br />
521-
<br />
522-
523-
524-
<!-- ------------------------ FLUSH GET REQUEST ------------------------ -->
525-
526-
527-
## `flushGetRequests`
528-
529-
Flushes any pending requests using a single batch call to get the data.
530-
531-
**Signature**:
532-
533-
```js
534-
static flushGetRequests(): void
535-
```
536-
537-
**Returns**:
538-
539-
`undefined`
540-
541-
542506
<!-- ------------------------ HOOKS ------------------------ -->
543507
544508

website/docs/Installation.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
id: install
3+
title: Installation
4+
sidebar_label: Installation
5+
---
6+
7+
8+
9+
### Get library
10+
11+
```bash
12+
yarn add @react-native-community/async-storage
13+
```
14+
15+
### Link
16+
17+
- **React Native 0.60+**
18+
19+
[CLI autolink feature](https://github.com/react-native-community/cli/blob/master/docs/autolinking.md) links the module while building the app.
20+
21+
Use CocoaPods to add the native `RNAsyncStorage` to your project:
22+
23+
```bash
24+
npx pod-install
25+
```
26+
27+
- **React Native <= 0.59**
28+
29+
30+
```bash
31+
react-native link @react-native-community/async-storage
32+
```
33+
34+
*Note:* For `Windows` the [manual linking](link) is currently the only linking option.

0 commit comments

Comments
 (0)