├── .DS_Store
├── .eslintrc.js
├── .gitignore
├── README.md
├── babel.config.js
├── build
├── ReactNativeUserDefaults.d.ts
├── ReactNativeUserDefaults.d.ts.map
├── ReactNativeUserDefaults.ios.d.ts
├── ReactNativeUserDefaults.ios.d.ts.map
├── ReactNativeUserDefaults.ios.js
├── ReactNativeUserDefaults.ios.js.map
├── ReactNativeUserDefaults.js
├── ReactNativeUserDefaults.js.map
├── index.d.ts
├── index.d.ts.map
├── index.js
└── index.js.map
├── expo-module.config.json
├── ios
├── ReactNativeUserDefaults.podspec
└── ReactNativeUserDefaultsModule.swift
├── package.json
├── src
├── ReactNativeUserDefaults.ios.ts
├── ReactNativeUserDefaults.ts
└── index.ts
├── tsconfig.json
└── yarn.lock
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andrew-levy/react-native-userdefaults/6526a494c6e3f72e14609c64e6dd8089ef6e028a/.DS_Store
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | extends: ['universe/native', 'universe/web'],
4 | ignorePatterns: ['build'],
5 | };
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # UserDefaults
2 |
3 | An interface to the user’s defaults database, where you store key-value pairs persistently across launches of your app. Inspired by [UserDefaults](https://developer.apple.com/documentation/foundation/userdefaults).
4 |
5 | - :white_check_mark: Built with [Expo's Module API](https://docs.expo.dev/modules/module-api/)
6 | - :white_check_mark: Written in TypeScript and Swift
7 | - :apple: Currently iOS only
8 |
9 | ## Installation
10 |
11 | 1. Install the package
12 |
13 | ```console
14 | yarn add @alevy97/react-native-userdefaults
15 | ```
16 |
17 | 2. Install pods
18 |
19 | ```console
20 | npx pod-install
21 | ```
22 |
23 | ## Usage
24 |
25 | ### Standard Defaults
26 |
27 | The most common use case for using `UserDefaults` is to store small chunks of data to the standard defaults system. You can access the standard defaults system using the static property `UserDefaults.standard` or by creating a new `UserDefaults` instance.
28 |
29 | ```tsx
30 | UserDefaults.standard;
31 | ```
32 |
33 | or equivalently
34 |
35 | ```tsx
36 | new UserDefaults();
37 | ```
38 |
39 | ### Defaults with Suite Name
40 |
41 | UserDefaults can also be used to store data that can be shared across multiple apps belonging to the same [App Group](https://developer.apple.com/documentation/xcode/configuring-app-groups?changes=_3), also known as a suite. To achieve this, provide a suite name (app group identifier) when creating a `UserDefaults` instance.
42 |
43 | ```tsx
44 | new UserDefaults("group.com.example.app");
45 | ```
46 |
47 | ### Example
48 |
49 | ```tsx
50 | import { Button, View } from "react-native";
51 | import UserDefaults from "@alevy97/react-native-userdefaults";
52 |
53 | const standardDefaults = UserDefaults.standard; // or new UserDefaults()
54 | const groupDefaults = new UserDefaults("group.com.example.app");
55 |
56 | function App() {
57 | return (
58 |
59 |
75 | );
76 | }
77 | ```
78 |
79 | ## API
80 |
81 | ```typescript
82 | interface UserDefaults {
83 | /* Standard user defaults object */
84 | standard: UserDefaults;
85 | /* Get the value for a given key */
86 | get(forKey: string): Promise;
87 | /* Set a value for a given key */
88 | set(forKey: string, value: any): Promise;
89 | /* Remove a value for a given key */
90 | remove(forKey: string): Promise;
91 | /* Removes all user default values */
92 | removeAll(): Promise;
93 | /* Returns all user default values */
94 | getAll(): Promise<{ [key: string]: any }>;
95 | }
96 | ```
97 |
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = function (api) {
2 | api.cache(true);
3 | return {
4 | presets: ['babel-preset-expo'],
5 | };
6 | };
7 |
--------------------------------------------------------------------------------
/build/ReactNativeUserDefaults.d.ts:
--------------------------------------------------------------------------------
1 | export default class UserDefaults {
2 | }
3 | //# sourceMappingURL=ReactNativeUserDefaults.d.ts.map
--------------------------------------------------------------------------------
/build/ReactNativeUserDefaults.d.ts.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"ReactNativeUserDefaults.d.ts","sourceRoot":"","sources":["../src/ReactNativeUserDefaults.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,YAAY;CAAG"}
--------------------------------------------------------------------------------
/build/ReactNativeUserDefaults.ios.d.ts:
--------------------------------------------------------------------------------
1 | export default class UserDefaults {
2 | private suiteName;
3 | private isStandard;
4 | static standard: UserDefaults;
5 | constructor(suiteName?: string);
6 | get(forKey: string): Promise;
7 | set(forKey: string, value: any): Promise;
8 | remove(forKey: string): Promise;
9 | getAll(): Promise;
10 | removeAll(): Promise;
11 | }
12 | //# sourceMappingURL=ReactNativeUserDefaults.ios.d.ts.map
--------------------------------------------------------------------------------
/build/ReactNativeUserDefaults.ios.d.ts.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"ReactNativeUserDefaults.ios.d.ts","sourceRoot":"","sources":["../src/ReactNativeUserDefaults.ios.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,OAAO,OAAO,YAAY;IAC/B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,UAAU,CAAU;IAE5B,MAAM,CAAC,QAAQ,eAAsB;gBAEzB,SAAS,CAAC,EAAE,MAAM;IAKxB,GAAG,CAAC,MAAM,EAAE,MAAM;IAQlB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG;IA4C9B,MAAM,CAAC,MAAM,EAAE,MAAM;IAOrB,MAAM;IAMN,SAAS;CAMhB"}
--------------------------------------------------------------------------------
/build/ReactNativeUserDefaults.ios.js:
--------------------------------------------------------------------------------
1 | import { requireNativeModule } from "expo-modules-core";
2 | const ReactNativeUserDefaults = requireNativeModule("ReactNativeUserDefaults");
3 | export default class UserDefaults {
4 | suiteName;
5 | isStandard;
6 | static standard = new UserDefaults();
7 | constructor(suiteName) {
8 | this.isStandard = suiteName === undefined;
9 | this.suiteName = suiteName || "";
10 | }
11 | async get(forKey) {
12 | const result = await ReactNativeUserDefaults.get(forKey, this.suiteName, this.isStandard);
13 | return result === null ? undefined : result;
14 | }
15 | async set(forKey, value) {
16 | if (value === undefined || value === null) {
17 | return await this.remove(forKey);
18 | }
19 | switch (typeof value) {
20 | case "string":
21 | return await ReactNativeUserDefaults.setString(forKey, value, this.suiteName, this.isStandard);
22 | case "number":
23 | return await ReactNativeUserDefaults.setNumber(forKey, value, this.suiteName, this.isStandard);
24 | case "boolean":
25 | return await ReactNativeUserDefaults.setBool(forKey, value, this.suiteName, this.isStandard);
26 | case "object":
27 | if (Array.isArray(value)) {
28 | return await ReactNativeUserDefaults.setArray(forKey, value, this.suiteName, this.isStandard);
29 | }
30 | return await ReactNativeUserDefaults.setObject(forKey, value, this.suiteName, this.isStandard);
31 | }
32 | }
33 | async remove(forKey) {
34 | return await ReactNativeUserDefaults.remove(forKey, this.suiteName, this.isStandard);
35 | }
36 | async getAll() {
37 | return await ReactNativeUserDefaults.getAll(this.suiteName, this.isStandard);
38 | }
39 | async removeAll() {
40 | return await ReactNativeUserDefaults.removeAll(this.suiteName, this.isStandard);
41 | }
42 | }
43 | //# sourceMappingURL=ReactNativeUserDefaults.ios.js.map
--------------------------------------------------------------------------------
/build/ReactNativeUserDefaults.ios.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"ReactNativeUserDefaults.ios.js","sourceRoot":"","sources":["../src/ReactNativeUserDefaults.ios.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,MAAM,uBAAuB,GAAG,mBAAmB,CAAC,yBAAyB,CAAC,CAAC;AAE/E,MAAM,CAAC,OAAO,OAAO,YAAY;IACvB,SAAS,CAAS;IAClB,UAAU,CAAU;IAE5B,MAAM,CAAC,QAAQ,GAAG,IAAI,YAAY,EAAE,CAAC;IAErC,YAAY,SAAkB;QAC5B,IAAI,CAAC,UAAU,GAAG,SAAS,KAAK,SAAS,CAAC;QAC1C,IAAI,CAAC,SAAS,GAAG,SAAS,IAAI,EAAE,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,MAAc;QACtB,MAAM,MAAM,GAAG,MAAM,uBAAuB,CAAC,GAAG,CAC9C,MAAM,EACN,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,UAAU,CAChB,CAAC;QACF,OAAO,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC;IAC9C,CAAC;IACD,KAAK,CAAC,GAAG,CAAC,MAAc,EAAE,KAAU;QAClC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE;YACzC,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;SAClC;QACD,QAAQ,OAAO,KAAK,EAAE;YACpB,KAAK,QAAQ;gBACX,OAAO,MAAM,uBAAuB,CAAC,SAAS,CAC5C,MAAM,EACN,KAAK,EACL,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,UAAU,CAChB,CAAC;YACJ,KAAK,QAAQ;gBACX,OAAO,MAAM,uBAAuB,CAAC,SAAS,CAC5C,MAAM,EACN,KAAK,EACL,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,UAAU,CAChB,CAAC;YACJ,KAAK,SAAS;gBACZ,OAAO,MAAM,uBAAuB,CAAC,OAAO,CAC1C,MAAM,EACN,KAAK,EACL,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,UAAU,CAChB,CAAC;YACJ,KAAK,QAAQ;gBACX,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;oBACxB,OAAO,MAAM,uBAAuB,CAAC,QAAQ,CAC3C,MAAM,EACN,KAAK,EACL,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,UAAU,CAChB,CAAC;iBACH;gBACD,OAAO,MAAM,uBAAuB,CAAC,SAAS,CAC5C,MAAM,EACN,KAAK,EACL,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,UAAU,CAChB,CAAC;SACL;IACH,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,MAAc;QACzB,OAAO,MAAM,uBAAuB,CAAC,MAAM,CACzC,MAAM,EACN,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,UAAU,CAChB,CAAC;IACJ,CAAC;IACD,KAAK,CAAC,MAAM;QACV,OAAO,MAAM,uBAAuB,CAAC,MAAM,CACzC,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,UAAU,CAChB,CAAC;IACJ,CAAC;IACD,KAAK,CAAC,SAAS;QACb,OAAO,MAAM,uBAAuB,CAAC,SAAS,CAC5C,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,UAAU,CAChB,CAAC;IACJ,CAAC","sourcesContent":["import { requireNativeModule } from \"expo-modules-core\";\n\nconst ReactNativeUserDefaults = requireNativeModule(\"ReactNativeUserDefaults\");\n\nexport default class UserDefaults {\n private suiteName: string;\n private isStandard: boolean;\n\n static standard = new UserDefaults();\n\n constructor(suiteName?: string) {\n this.isStandard = suiteName === undefined;\n this.suiteName = suiteName || \"\";\n }\n\n async get(forKey: string) {\n const result = await ReactNativeUserDefaults.get(\n forKey,\n this.suiteName,\n this.isStandard\n );\n return result === null ? undefined : result;\n }\n async set(forKey: string, value: any) {\n if (value === undefined || value === null) {\n return await this.remove(forKey);\n }\n switch (typeof value) {\n case \"string\":\n return await ReactNativeUserDefaults.setString(\n forKey,\n value,\n this.suiteName,\n this.isStandard\n );\n case \"number\":\n return await ReactNativeUserDefaults.setNumber(\n forKey,\n value,\n this.suiteName,\n this.isStandard\n );\n case \"boolean\":\n return await ReactNativeUserDefaults.setBool(\n forKey,\n value,\n this.suiteName,\n this.isStandard\n );\n case \"object\":\n if (Array.isArray(value)) {\n return await ReactNativeUserDefaults.setArray(\n forKey,\n value,\n this.suiteName,\n this.isStandard\n );\n }\n return await ReactNativeUserDefaults.setObject(\n forKey,\n value,\n this.suiteName,\n this.isStandard\n );\n }\n }\n\n async remove(forKey: string) {\n return await ReactNativeUserDefaults.remove(\n forKey,\n this.suiteName,\n this.isStandard\n );\n }\n async getAll() {\n return await ReactNativeUserDefaults.getAll(\n this.suiteName,\n this.isStandard\n );\n }\n async removeAll() {\n return await ReactNativeUserDefaults.removeAll(\n this.suiteName,\n this.isStandard\n );\n }\n}\n"]}
--------------------------------------------------------------------------------
/build/ReactNativeUserDefaults.js:
--------------------------------------------------------------------------------
1 | export default class UserDefaults {
2 | }
3 | //# sourceMappingURL=ReactNativeUserDefaults.js.map
--------------------------------------------------------------------------------
/build/ReactNativeUserDefaults.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"ReactNativeUserDefaults.js","sourceRoot":"","sources":["../src/ReactNativeUserDefaults.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,YAAY;CAAG","sourcesContent":["export default class UserDefaults {}\n"]}
--------------------------------------------------------------------------------
/build/index.d.ts:
--------------------------------------------------------------------------------
1 | import UserDefaults from "./ReactNativeUserDefaults";
2 | export default UserDefaults;
3 | //# sourceMappingURL=index.d.ts.map
--------------------------------------------------------------------------------
/build/index.d.ts.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,2BAA2B,CAAC;AACrD,eAAe,YAAY,CAAC"}
--------------------------------------------------------------------------------
/build/index.js:
--------------------------------------------------------------------------------
1 | import UserDefaults from "./ReactNativeUserDefaults";
2 | export default UserDefaults;
3 | //# sourceMappingURL=index.js.map
--------------------------------------------------------------------------------
/build/index.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,2BAA2B,CAAC;AACrD,eAAe,YAAY,CAAC","sourcesContent":["import UserDefaults from \"./ReactNativeUserDefaults\";\nexport default UserDefaults;\n"]}
--------------------------------------------------------------------------------
/expo-module.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "platforms": ["ios"],
3 | "ios": {
4 | "modules": ["ReactNativeUserDefaultsModule"]
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/ios/ReactNativeUserDefaults.podspec:
--------------------------------------------------------------------------------
1 | require 'json'
2 |
3 | package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))
4 |
5 | Pod::Spec.new do |s|
6 | s.name = 'ReactNativeUserDefaults'
7 | s.version = package['version']
8 | s.summary = package['description']
9 | s.description = package['description']
10 | s.license = package['license']
11 | s.author = package['author']
12 | s.homepage = package['homepage']
13 | s.platform = :ios, '13.0'
14 | s.swift_version = '5.4'
15 | s.source = { git: 'https://github.com/andrew-levy/react-native-userdefaults' }
16 | s.static_framework = true
17 |
18 | s.dependency 'ExpoModulesCore'
19 |
20 | # Swift/Objective-C compatibility
21 | s.pod_target_xcconfig = {
22 | 'DEFINES_MODULE' => 'YES',
23 | 'SWIFT_COMPILATION_MODE' => 'wholemodule'
24 | }
25 |
26 | s.source_files = "**/*.{h,m,swift}"
27 | end
28 |
--------------------------------------------------------------------------------
/ios/ReactNativeUserDefaultsModule.swift:
--------------------------------------------------------------------------------
1 | import ExpoModulesCore
2 |
3 | public class ReactNativeUserDefaultsModule: Module {
4 |
5 | public func definition() -> ModuleDefinition {
6 | Name("ReactNativeUserDefaults")
7 |
8 | AsyncFunction("setString") { (forKey: String, value: String, suiteName: String, isStandard: Bool) in
9 | let userDefaults = isStandard ? UserDefaults.standard : UserDefaults(suiteName: suiteName)
10 | userDefaults?.set(value, forKey: forKey)
11 | }
12 |
13 | AsyncFunction("setBool") { (forKey: String, value: Bool, suiteName: String, isStandard: Bool) in
14 | let userDefaults = isStandard ? UserDefaults.standard : UserDefaults(suiteName: suiteName)
15 | userDefaults?.set(value, forKey: forKey)
16 | }
17 |
18 | AsyncFunction("setArray") { (forKey: String, value: [Any], suiteName: String, isStandard: Bool) in
19 | let userDefaults = isStandard ? UserDefaults.standard : UserDefaults(suiteName: suiteName)
20 | userDefaults?.set(value, forKey: forKey)
21 | }
22 |
23 | AsyncFunction("setObject") { (forKey: String, value: [String: Any], suiteName: String, isStandard: Bool) in
24 | let userDefaults = isStandard ? UserDefaults.standard : UserDefaults(suiteName: suiteName)
25 | userDefaults?.set(value, forKey: forKey)
26 | }
27 |
28 | AsyncFunction("setNumber") { (forKey: String, value: Double, suiteName: String, isStandard: Bool) in
29 | let userDefaults = isStandard ? UserDefaults.standard : UserDefaults(suiteName: suiteName)
30 | userDefaults?.set(value, forKey: forKey)
31 | }
32 |
33 | AsyncFunction("get") { (forKey: String, suiteName: String, isStandard: Bool) -> Any? in
34 | let userDefaults = isStandard ? UserDefaults.standard : UserDefaults(suiteName: suiteName)
35 | return userDefaults?.object(forKey: forKey)
36 | }
37 |
38 | AsyncFunction("getAll") { (suiteName: String, isStandard: Bool) -> [String : Any] in
39 | let userDefaults = isStandard ? UserDefaults.standard : UserDefaults(suiteName: suiteName)
40 | return userDefaults?.dictionaryRepresentation() ?? [:]
41 | }
42 |
43 | AsyncFunction("remove") { (forKey: String, suiteName: String, isStandard: Bool) in
44 | let userDefaults = isStandard ? UserDefaults.standard : UserDefaults(suiteName: suiteName)
45 | userDefaults?.removeObject(forKey: forKey)
46 | }
47 |
48 | AsyncFunction("removeAll") { (suiteName: String, isStandard: Bool) in
49 | let userDefaults = isStandard ? UserDefaults.standard : UserDefaults(suiteName: suiteName)
50 | userDefaults?.dictionaryRepresentation().forEach { (key: String, value: Any) in
51 | userDefaults?.removeObject(forKey: key)
52 | }
53 | }
54 |
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@alevy97/react-native-userdefaults",
3 | "version": "0.2.2",
4 | "description": "UserDefaults in React Native",
5 | "main": "build/index.js",
6 | "types": "build/index.d.ts",
7 | "scripts": {
8 | "build": "expo-module build",
9 | "lint": "expo-module lint"
10 | },
11 | "keywords": [
12 | "react-native",
13 | "expo",
14 | "react-native-userdefaults",
15 | "ReactNativeUserDefaults"
16 | ],
17 | "repository": "https://github.com/andrew-levy/react-native-userdefaults",
18 | "author": "Andrew Levy",
19 | "license": "MIT",
20 | "homepage": "https://github.com/andrew-levy/react-native-userdefaults",
21 | "devDependencies": {
22 | "@types/react": "^18.0.25",
23 | "@types/react-native": "^0.70.6",
24 | "expo-module-scripts": "^3.0.3",
25 | "expo-modules-core": "^1.0.3"
26 | },
27 | "peerDependencies": {
28 | "expo": "*",
29 | "react": "*",
30 | "react-native": "*"
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/ReactNativeUserDefaults.ios.ts:
--------------------------------------------------------------------------------
1 | import { requireNativeModule } from "expo-modules-core";
2 |
3 | const ReactNativeUserDefaults = requireNativeModule("ReactNativeUserDefaults");
4 |
5 | export default class UserDefaults {
6 | private suiteName: string;
7 | private isStandard: boolean;
8 |
9 | static standard = new UserDefaults();
10 |
11 | constructor(suiteName?: string) {
12 | this.isStandard = suiteName === undefined;
13 | this.suiteName = suiteName || "";
14 | }
15 |
16 | async get(forKey: string) {
17 | const result = await ReactNativeUserDefaults.get(
18 | forKey,
19 | this.suiteName,
20 | this.isStandard
21 | );
22 | return result === null ? undefined : result;
23 | }
24 | async set(forKey: string, value: any) {
25 | if (value === undefined || value === null) {
26 | return await this.remove(forKey);
27 | }
28 | switch (typeof value) {
29 | case "string":
30 | return await ReactNativeUserDefaults.setString(
31 | forKey,
32 | value,
33 | this.suiteName,
34 | this.isStandard
35 | );
36 | case "number":
37 | return await ReactNativeUserDefaults.setNumber(
38 | forKey,
39 | value,
40 | this.suiteName,
41 | this.isStandard
42 | );
43 | case "boolean":
44 | return await ReactNativeUserDefaults.setBool(
45 | forKey,
46 | value,
47 | this.suiteName,
48 | this.isStandard
49 | );
50 | case "object":
51 | if (Array.isArray(value)) {
52 | return await ReactNativeUserDefaults.setArray(
53 | forKey,
54 | value,
55 | this.suiteName,
56 | this.isStandard
57 | );
58 | }
59 | return await ReactNativeUserDefaults.setObject(
60 | forKey,
61 | value,
62 | this.suiteName,
63 | this.isStandard
64 | );
65 | }
66 | }
67 |
68 | async remove(forKey: string) {
69 | return await ReactNativeUserDefaults.remove(
70 | forKey,
71 | this.suiteName,
72 | this.isStandard
73 | );
74 | }
75 | async getAll() {
76 | return await ReactNativeUserDefaults.getAll(
77 | this.suiteName,
78 | this.isStandard
79 | );
80 | }
81 | async removeAll() {
82 | return await ReactNativeUserDefaults.removeAll(
83 | this.suiteName,
84 | this.isStandard
85 | );
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/src/ReactNativeUserDefaults.ts:
--------------------------------------------------------------------------------
1 | export default class UserDefaults {}
2 |
--------------------------------------------------------------------------------
/src/index.ts:
--------------------------------------------------------------------------------
1 | import UserDefaults from "./ReactNativeUserDefaults";
2 | export default UserDefaults;
3 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | // @generated by expo-module-scripts
2 | {
3 | "extends": "expo-module-scripts/tsconfig.base",
4 | "compilerOptions": {
5 | "outDir": "./build"
6 | },
7 | "include": ["./src"],
8 | "exclude": ["**/__mocks__/*", "**/__tests__/*"]
9 | }
10 |
--------------------------------------------------------------------------------