|
1 |
| -# async-storage |
| 1 | +# `@reason-react-native/async-storage` |
| 2 | + |
| 3 | +[](https://github.com/reason-react-native/async-storage/actions) |
| 4 | +[](https://www.npmjs.com/@reason-react-native/async-storage) |
| 5 | +[](https://reasonml-community.github.io/reason-react-native/discord/) |
| 6 | + |
| 7 | +[ReasonML](https://reasonml.github.io) / |
| 8 | +[BuckleScript](https://bucklescript.github.io) bindings for |
| 9 | +[`@react-native-community/async-storage`](https://github.com/react-native-community/async-storage). |
| 10 | + |
| 11 | +Exposed as `ReactNativeAsyncStorage` module. |
| 12 | + |
| 13 | +`@reason-react-native/async-storage` X.y._ means it's compatible with |
| 14 | +`@react-native-community/async-storage` X.y._ |
| 15 | + |
| 16 | +## Installation |
| 17 | + |
| 18 | +When |
| 19 | +[`@react-native-community/async-storage`](`https://github.com/react-native-community/async-storage`) |
| 20 | +is properly installed & configured by following their installation instructions, |
| 21 | +you can install the bindings: |
| 22 | + |
| 23 | +```console |
| 24 | +npm install @reason-react-native/async-storage |
| 25 | +# or |
| 26 | +yarn add @reason-react-native/async-storage |
| 27 | +``` |
| 28 | + |
| 29 | +`@reason-react-native/async-storage` should be added to `bs-dependencies` in |
| 30 | +your `bsconfig.json`. Something like |
| 31 | + |
| 32 | +```diff |
| 33 | +{ |
| 34 | + //... |
| 35 | + "bs-dependencies": [ |
| 36 | + "reason-react", |
| 37 | + "reason-react-native", |
| 38 | + // ... |
| 39 | ++ "@reason-react-native/async-storage" |
| 40 | + ], |
| 41 | + //... |
| 42 | +} |
| 43 | +``` |
| 44 | + |
| 45 | +## Usage |
| 46 | + |
| 47 | +### Types |
| 48 | + |
| 49 | +#### `ReactNativeAsyncStorage.asyncStorageState` |
| 50 | + |
| 51 | +```re |
| 52 | +{ |
| 53 | + . |
| 54 | + [@bs.meth] "getItem": unit => Js.Promise.t(Js.Null.t(string)), |
| 55 | + [@bs.meth] "setItem": string => Js.Promise.t(unit), |
| 56 | + [@bs.meth] "mergeItem": string => Js.Promise.t(unit), |
| 57 | + [@bs.meth] "removeItem": unit => Js.Promise.t(unit), |
| 58 | +} |
| 59 | +``` |
| 60 | + |
| 61 | +### Methods |
| 62 | + |
| 63 | +#### `ReactNativeAsyncStorage.getItem` |
| 64 | + |
| 65 | +```re |
| 66 | +string => Js.Promise.t(Js.Null.t(string)) |
| 67 | +``` |
| 68 | + |
| 69 | +#### `ReactNativeAsyncStorage.setItem` |
| 70 | + |
| 71 | +```re |
| 72 | +(string, string) => Js.Promise.t(unit) |
| 73 | +``` |
| 74 | + |
| 75 | +#### `ReactNativeAsyncStorage.removeItem` |
| 76 | + |
| 77 | +```re |
| 78 | +string => Js.Promise.t(unit) |
| 79 | +``` |
| 80 | + |
| 81 | +#### `ReactNativeAsyncStorage.mergeItem` |
| 82 | + |
| 83 | +```re |
| 84 | +(string, string) => Js.Promise.t(unit) |
| 85 | +``` |
| 86 | + |
| 87 | +#### `ReactNativeAsyncStorage.clear` |
| 88 | + |
| 89 | +```re |
| 90 | +unit => Js.Promise.t(unit) |
| 91 | +``` |
| 92 | + |
| 93 | +#### `ReactNativeAsyncStorage.getAllKeys` |
| 94 | + |
| 95 | +```re |
| 96 | +unit => Js.Promise.t(Js.Null.t(array(string))) |
| 97 | +``` |
| 98 | + |
| 99 | +#### `ReactNativeAsyncStorage.multiGet` |
| 100 | + |
| 101 | +```re |
| 102 | +array(string) => Js.Promise.t(array((string, Js.Null.t(string)))) |
| 103 | +``` |
| 104 | +
|
| 105 | +#### `ReactNativeAsyncStorage.multiSet` |
| 106 | +
|
| 107 | +```re |
| 108 | +array((string, string)) => Js.Promise.t(unit) |
| 109 | +``` |
| 110 | + |
| 111 | +#### `ReactNativeAsyncStorage.multiMerge` |
| 112 | + |
| 113 | +```re |
| 114 | +array((string, string)) => Js.Promise.t(unit) |
| 115 | +``` |
| 116 | +
|
| 117 | +#### `ReactNativeAsyncStorage.multiRemove` |
| 118 | +
|
| 119 | +```re |
| 120 | +array(string) => Js.Promise.t(unit) |
| 121 | +``` |
| 122 | + |
| 123 | +#### `ReactNativeAsyncStorage.flushGetRequests` |
| 124 | + |
| 125 | +```re |
| 126 | +unit => unit |
| 127 | +``` |
| 128 | + |
| 129 | +#### `ReactNativeAsyncStorage.useAsyncStorage` |
| 130 | + |
| 131 | +```re |
| 132 | +string => asyncStorageState |
| 133 | +``` |
| 134 | + |
| 135 | +--- |
| 136 | + |
| 137 | +## Changelog |
| 138 | + |
| 139 | +Check the [changelog](./CHANGELOG.md) for more informations about recent |
| 140 | +releases. |
| 141 | + |
| 142 | +--- |
| 143 | + |
| 144 | +## Contribute |
| 145 | + |
| 146 | +Read the |
| 147 | +[contribution guidelines](https://github.com/reason-react-native/.github/blob/master/CONTRIBUTING.md) |
| 148 | +before contributing. |
| 149 | + |
| 150 | +## Code of Conduct |
| 151 | + |
| 152 | +We want this community to be friendly and respectful to each other. Please read |
| 153 | +[our full code of conduct](https://github.com/reason-react-native/.github/blob/master/CODE_OF_CONDUCT.md) |
| 154 | +so that you can understand what actions will and will not be tolerated. |
0 commit comments