Skip to content

Commit 5573359

Browse files
committed
Add binding for useAsyncStorage for both notation, to avoid breaking changes
Ref #4
1 parent 78387c7 commit 5573359

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/ReactNativeAsyncStorage.re

+14-1
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,24 @@ external multiRemove: array(string) => Js.Promise.t(unit) = "multiRemove";
3737
external flushGetRequests: unit => unit = "flushGetRequests";
3838

3939
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+
[@deprecated
48+
"Please use `useAsyncStorage_` instead of `useAsyncStorage` to use record syntax. In next major release, `useAsyncStorage_` will become `useAsyncStorage`."
49+
]
50+
[@bs.module "@react-native-async-storage/async-storage"]
51+
external useAsyncStorage: string => asyncStorageState = "useAsyncStorage";
52+
type asyncStorageStateAlt = {
4053
getItem: unit => Js.Promise.t(Js.Null.t(string)),
4154
setItem: string => Js.Promise.t(unit),
4255
mergeItem: string => Js.Promise.t(unit),
4356
removeItem: unit => Js.Promise.t(unit),
4457
};
4558

4659
[@bs.module "@react-native-async-storage/async-storage"]
47-
external useAsyncStorage: string => asyncStorageState = "useAsyncStorage";
60+
external useAsyncStorage_: string => asyncStorageState = "useAsyncStorage";

0 commit comments

Comments
 (0)