Skip to content

Commit 6c7be95

Browse files
tatchiMoOx
authored andcommitted
async-storage bindings (#1)
* base async-storage bindings * removed react-native & reason-react-native deps * added useAsyncStorage binding
1 parent c37827b commit 6c7be95

6 files changed

+133
-0
lines changed

.gitignore

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Ocaml / Reason / BuckleScript artifacts
2+
.bsb.lock
3+
**/lib/bs
4+
**/lib/ocaml
5+
**/.merlin
6+
7+
# macos crap
8+
.DS_Store
9+
# node
10+
node_modules
11+
# npm unused lock file (we use yarn.lock)
12+
package-lock.json

bsconfig.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "@reason-react-native/async-storage",
3+
"refmt": 3,
4+
"reason": {
5+
"react-jsx": 3
6+
},
7+
"package-specs": {
8+
"module": "commonjs",
9+
"in-source": true
10+
},
11+
"suffix": ".bs.js",
12+
"sources": [
13+
{
14+
"dir": "src",
15+
"subdirs": false
16+
}
17+
],
18+
"bsc-flags": ["-bs-no-version-header", "-warn-error @a"],
19+
"bs-dependencies": []
20+
}

package.json

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "@reason-react-native/async-storage",
3+
"version": "0.0.1",
4+
"publishConfig": {
5+
"access": "public"
6+
},
7+
"author": "tatchi (https://github.com/tatchi)",
8+
"repository": "https://github.com/reason-react-native/async-storage.git",
9+
"license": "MIT",
10+
"keywords": [
11+
"reason",
12+
"reasonml",
13+
"bucklescript",
14+
"react-native",
15+
"react-native-async-storage",
16+
"async-storage"
17+
],
18+
"files": [
19+
"*",
20+
"!.DS_Store",
21+
"!**/*.bs.js",
22+
"!.merlin",
23+
"!lib/bs",
24+
"!lib/ocaml"
25+
],
26+
"scripts": {
27+
"start": "bsb -make-world -w",
28+
"build": "bsb -make-world",
29+
"clean": "bsb -clean-world",
30+
"test": "bsb -clean-world -make-world"
31+
},
32+
"devDependencies": {
33+
"bs-platform": "^5.0.4",
34+
"@react-native-community/async-storage": "^1.6.1"
35+
},
36+
"peerDependencies": {
37+
"@react-native-community/async-storage": "^1.6.1"
38+
}
39+
}

src/ReactNativeAsyncStorage.bs.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */

src/ReactNativeAsyncStorage.re

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
[@bs.scope "default"] [@bs.module "@react-native-community/async-storage"]
2+
external getItem: string => Js.Promise.t(Js.Null.t(string)) = "getItem";
3+
4+
[@bs.scope "default"] [@bs.module "@react-native-community/async-storage"]
5+
external setItem: (string, string) => Js.Promise.t(unit) = "setItem";
6+
7+
[@bs.scope "default"] [@bs.module "@react-native-community/async-storage"]
8+
external removeItem: string => Js.Promise.t(unit) = "removeItem";
9+
10+
[@bs.scope "default"] [@bs.module "@react-native-community/async-storage"]
11+
external mergeItem: (string, string) => Js.Promise.t(unit) = "mergeItem";
12+
13+
[@bs.scope "default"] [@bs.module "@react-native-community/async-storage"]
14+
external clear: unit => Js.Promise.t(unit) = "clear";
15+
16+
[@bs.scope "default"] [@bs.module "@react-native-community/async-storage"]
17+
external getAllKeys: unit => Js.Promise.t(Js.Null.t(array(string))) =
18+
"getAllKeys";
19+
20+
[@bs.scope "default"] [@bs.module "@react-native-community/async-storage"]
21+
external multiGet:
22+
array(string) => Js.Promise.t(array((string, Js.Null.t(string)))) =
23+
"multiGet";
24+
25+
[@bs.scope "default"] [@bs.module "@react-native-community/async-storage"]
26+
external multiSet: array((string, string)) => Js.Promise.t(unit) =
27+
"multiSet";
28+
29+
[@bs.scope "default"] [@bs.module "@react-native-community/async-storage"]
30+
external multiMerge: array((string, string)) => Js.Promise.t(unit) =
31+
"multiMerge";
32+
33+
[@bs.scope "default"] [@bs.module "@react-native-community/async-storage"]
34+
external multiRemove: array(string) => Js.Promise.t(unit) = "multiRemove";
35+
36+
[@bs.scope "default"] [@bs.module "@react-native-community/async-storage"]
37+
external flushGetRequests: unit => unit = "flushGetRequests";
38+
39+
type asyncStorageState = {
40+
.
41+
[@bs.meth] "getItem": unit => Js.Promise.t(Js.Null.t(string)),
42+
[@bs.meth] "setItem": string => Js.Promise.t(unit),
43+
[@bs.meth] "mergeItem": string => Js.Promise.t(unit),
44+
[@bs.meth] "removeItem": unit => Js.Promise.t(unit),
45+
};
46+
47+
[@bs.module "@react-native-community/async-storage"]
48+
external useAsyncStorage: string => asyncStorageState = "useAsyncStorage";

yarn.lock

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
"@react-native-community/async-storage@^1.6.1":
6+
version "1.6.1"
7+
resolved "https://registry.yarnpkg.com/@react-native-community/async-storage/-/async-storage-1.6.1.tgz#19be07fc1d65c77bdeb20f46108ba12076aad1c5"
8+
integrity sha512-1WA28xfdhG+unkTEk/lXnqI2izv6belo0CYw7UdvaeHm8TIYT6eTmIIdGR7oiCa2xSKEnaPQqRMH6h7gyLNbww==
9+
10+
bs-platform@^5.0.4:
11+
version "5.0.6"
12+
resolved "https://registry.yarnpkg.com/bs-platform/-/bs-platform-5.0.6.tgz#88c13041fb020479800de3d82c680bf971091425"
13+
integrity sha512-6Boa2VEcWJp2WJr38L7bp3J929nYha7gDarjxb070jWzgfPJ/WbzjipmSfnu2eqqk1MfjEIpBipbPz6n1NISwA==

0 commit comments

Comments
 (0)