-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
78 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
const settingsModule = require('../Settings/Settings'); | ||
const REACT_DEVTOOLS_SETTINGS_KEY_PREFIX = 'ReactDevTools::Settings::'; | ||
|
||
export type CachedSettingsStore = { | ||
setValue: (key: string, value: string) => void, | ||
getValue: (key: string) => ?string, | ||
}; | ||
|
||
function getFullKey(suffix: string): string { | ||
return `${REACT_DEVTOOLS_SETTINGS_KEY_PREFIX}${suffix}`; | ||
} | ||
|
||
const cachedSettingsStore: CachedSettingsStore = { | ||
setValue: (key, value) => { | ||
try { | ||
settingsModule.set({ | ||
[getFullKey(key)]: value, | ||
}); | ||
} catch {} | ||
}, | ||
getValue: (key) => { | ||
try { | ||
return settingsModule.get(getFullKey(key)); | ||
} catch {} | ||
}, | ||
}; | ||
|
||
module.exports = cachedSettingsStore; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
ReactAndroid/src/main/java/com/facebook/react/modules/settings/BUCK
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_root_target", "react_native_target", "rn_android_library") | ||
|
||
rn_android_library( | ||
name = "settings", | ||
srcs = glob(["**/*.java"]), | ||
autoglob = False, | ||
labels = [ | ||
"pfh:ReactNative_CommonInfrastructurePlaceholder", | ||
"supermodule:xplat/default/public.react_native.infra", | ||
], | ||
language = "JAVA", | ||
visibility = [ | ||
"PUBLIC", | ||
], | ||
deps = [ | ||
react_native_dep("libraries/fbcore/src/main/java/com/facebook/common/logging:logging"), | ||
react_native_dep("third-party/java/infer-annotations:infer-annotations"), | ||
react_native_dep("third-party/java/jsr-305:jsr-305"), | ||
react_native_target("java/com/facebook/react/bridge:bridge"), | ||
react_native_target("java/com/facebook/react/common:common"), | ||
react_native_target("java/com/facebook/react/module/annotations:annotations"), | ||
react_native_target("java/com/facebook/react/modules/core:core"), | ||
], | ||
exported_deps = [react_native_root_target(":FBReactNativeSpec")], | ||
) |
16 changes: 16 additions & 0 deletions
16
ReactAndroid/src/main/java/com/facebook/react/modules/settings/SettingsManagerModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
package com.facebook.react.modules.settings; | ||
|
||
import com.facebook.fbreact.specs.NativeSettingsManagerSpec; | ||
import com.facebook.react.module.annotations.ReactModule; | ||
|
||
@ReactModule(name = SettingsManagerModule.NAME) | ||
public class SettingsManagerModule extends NativeSettingsManagerSpec { | ||
public static final String NAME = "SettingsManager"; | ||
} |