UNPKG

@scripty/react-store

Version:

This lightweight global react hook store is inspired by the extjs store architecture. Share your stores through your application with only a few lines of code!

18 lines (16 loc) 491 B
export const addStore = (store, name) => { if (!window.globalStorage.data.some(storage => { return storage.name === name })) { window.globalStorage.data.push(store); } return window.globalStorage; }; export const getStore = (store, name) => { return store.data.map((rec) => { if (rec.name === name) { return rec; } return []; }).filter(rec => Object.keys(rec).length > 0 || rec.length > 0)[0]; };