Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
rbalicki2 committed Oct 8, 2022
1 parent 31bedd9 commit 2902b69
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Libraries/Core/cachedSettingsStore.js
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: (s: string) => void,
getValue: () => ?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;
2 changes: 2 additions & 0 deletions Libraries/Core/setUpReactDevTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ if (__DEV__) {
});

const ReactNativeStyleAttributes = require('../Components/View/ReactNativeStyleAttributes');
const cachedSettingsStore = require('./cachedSettingsStore');

reactDevTools.connectToDevTools({
isAppActive,
Expand All @@ -70,6 +71,7 @@ if (__DEV__) {
ReactNativeStyleAttributes,
),
websocket: ws,
cachedSettingsStore,
});
}
};
Expand Down

0 comments on commit 2902b69

Please sign in to comment.