MCPcopy Index your code
hub / github.com/plotly/dash / tryGetWebStore

Function tryGetWebStore

dash/dash-renderer/src/persistence.js:222–255  ·  view source on GitHub ↗
(backEnd, dispatch)

Source from the content-addressed store, hash-verified

220};
221
222function tryGetWebStore(backEnd, dispatch) {
223 const store = new WebStore(backEnd);
224 const fallbackStore = stores.memory;
225 const storeTest = longString();
226 const testKey = storePrefix + 'x.x';
227 try {
228 store._setItem(testKey, storeTest);
229 if (store.getItem(testKey) !== storeTest) {
230 dispatch(
231 err(`${backEnd} init failed set/get, falling back to memory`)
232 );
233 return fallbackStore;
234 }
235 store.removeItem(testKey);
236 return store;
237 } catch (e) {
238 dispatch(
239 err(`${backEnd} init first try failed; clearing and retrying`)
240 );
241 }
242 try {
243 store.clear();
244 store._setItem(testKey, storeTest);
245 if (store.getItem(testKey) !== storeTest) {
246 throw new Error('nope');
247 }
248 store.removeItem(testKey);
249 dispatch(err(`${backEnd} init set/get succeeded after clearing!`));
250 return store;
251 } catch (e) {
252 dispatch(err(`${backEnd} init still failed, falling back to memory`));
253 return fallbackStore;
254 }
255}
256
257function getStore(type, dispatch) {
258 if (!stores[type]) {

Callers 1

getStoreFunction · 0.85

Calls 6

_setItemMethod · 0.95
getItemMethod · 0.95
removeItemMethod · 0.95
clearMethod · 0.95
errFunction · 0.85
longStringFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…