- updated internal docs;

This commit is contained in:
Vitalii Kiiko
2025-04-16 10:33:19 +02:00
parent c8bc0cf95a
commit 1d06aeef01

View File

@@ -1,4 +1,4 @@
// stores
// store API
import { mainStore } from './main';
import {
useStoreValue as useStoreValueOriginal,
@@ -6,19 +6,19 @@ import {
useTracked
} from 'zustand-x';
// migration: useStore -> useStoreValue
// old: useStore().main.getRole() -- new: useStoreValue('getRole')
// Hook. Subscribe to single store value with arguments
export const useStoreValue = (key, ...args) => useStoreValueOriginal(mainStore, key, ...args);
// Hook. Subscribe to the whole store (use ONLY if really needed (probably will not be needed though!))
export const useStoreState = (key, ...args) => useStoreStateOriginal(mainStore, key, ...args);
// migration: useTrackedStore -> useTrackedValue
// Hook. Subscribe to single store value no arguments
export const useTrackedValue = (key) => useTracked(mainStore, key);
// old: storeGet.main.getRole() -- new: storeGet('getRole')
// NOT hook. Get store value.
export const storeGet = (key, ...args) => mainStore.get(key, ...args);
// old: storeSet.main.removeElement(id) -- new: storeSet('removeElement', id)
// NOT hook. Set store value
export const storeSet = (key, ...args) => mainStore.set(key, ...args);
export default mainStore;