https://github.com/rescript-react-native/async-storage
ReScript bindings for @react-native-async-storage/async-storage
https://github.com/rescript-react-native/async-storage
async-storage react react-native rescript rescript-react rescript-react-native
Last synced: 6 months ago
JSON representation
ReScript bindings for @react-native-async-storage/async-storage
- Host: GitHub
- URL: https://github.com/rescript-react-native/async-storage
- Owner: rescript-react-native
- License: mit
- Created: 2019-08-30T12:47:14.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2023-02-09T03:17:59.000Z (almost 3 years ago)
- Last Synced: 2025-04-13T12:08:44.054Z (9 months ago)
- Topics: async-storage, react, react-native, rescript, rescript-react, rescript-react-native
- Language: ReScript
- Homepage:
- Size: 999 KB
- Stars: 12
- Watchers: 2
- Forks: 4
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# `@rescript-react-native/async-storage`
[](https://github.com/rescript-react-native/async-storage/actions)
[](https://www.npmjs.com/@rescript-react-native/async-storage)
[](https://forum.rescript-lang.org/)
[ReScript](https://rescript-lang.org) bindings for
[`@react-native-async-storage/async-storage`](https://github.com/react-native-async-storage/async-storage).
Exposed as `ReactNativeAsyncStorage` module.
`@rescript-react-native/async-storage` X.y.\* means it's compatible with
`@react-native-async-storage/async-storage` X.y.\*
## Installation
When
[`@react-native-async-storage/async-storage`](https://github.com/react-native-async-storage/async-storage)
is properly installed & configured by following their installation instructions,
you can install the bindings:
```console
npm install @rescript-react-native/async-storage
# or
yarn add @rescript-react-native/async-storage
```
`@rescript-react-native/async-storage` should be added to `bs-dependencies` in
your `bsconfig.json`:
```diff
{
//...
"bs-dependencies": [
"@rescript/react",
"rescript-react-native",
// ...
+ "@rescript-react-native/async-storage"
],
//...
}
```
## Usage
### Types
#### `ReactNativeAsyncStorage.asyncStorageState`
```rescript
type asyncStorageState = {
getItem: unit => Js.Promise.t(Js.Null.t(string)),
setItem: string => Js.Promise.t(unit),
mergeItem: string => Js.Promise.t(unit),
removeItem: unit => Js.Promise.t(unit),
};
let ReactNativeAsyncStorage.{getItem, setItem} =
ReactNativeAsyncStorage.useAsyncStorage("useAsyncStorage");
```
### Methods
#### `ReactNativeAsyncStorage.getItem`
```rescript
string => Js.Promise.t(Js.Null.t(string))
```
#### `ReactNativeAsyncStorage.setItem`
```rescript
(string, string) => Js.Promise.t(unit)
```
#### `ReactNativeAsyncStorage.removeItem`
```rescript
string => Js.Promise.t(unit)
```
#### `ReactNativeAsyncStorage.mergeItem`
```rescript
(string, string) => Js.Promise.t(unit)
```
#### `ReactNativeAsyncStorage.clear`
```rescript
unit => Js.Promise.t(unit)
```
#### `ReactNativeAsyncStorage.getAllKeys`
```rescript
unit => Js.Promise.t(Js.Null.t(array(string)))
```
#### `ReactNativeAsyncStorage.multiGet`
```rescript
array(string) => Js.Promise.t(array((string, Js.Null.t(string))))
```
#### `ReactNativeAsyncStorage.multiSet`
```rescript
array((string, string)) => Js.Promise.t(unit)
```
#### `ReactNativeAsyncStorage.multiMerge`
```rescript
array((string, string)) => Js.Promise.t(unit)
```
#### `ReactNativeAsyncStorage.multiRemove`
```rescript
array(string) => Js.Promise.t(unit)
```
#### `ReactNativeAsyncStorage.flushGetRequests`
```rescript
unit => unit
```
#### `ReactNativeAsyncStorage.useAsyncStorage`
```rescript
string => asyncStorageState
```
---
## Changelog
Check the [changelog](./CHANGELOG.md) for more informations about recent
releases.
---
## Contribute
Read the
[contribution guidelines](https://github.com/rescript-react-native/.github/blob/master/CONTRIBUTING.md)
before contributing.
## Code of Conduct
We want this community to be friendly and respectful to each other. Please read
[our full code of conduct](https://github.com/rescript-react-native/.github/blob/master/CODE_OF_CONDUCT.md)
so that you can understand what actions will and will not be tolerated.