mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-24 02:02:35 -04:00
13 lines
291 B
TypeScript
13 lines
291 B
TypeScript
import { get } from '@vueuse/core';
|
|
|
|
export function useRefreshableState<T>(key: string, getState: () => T | Ref<T>) {
|
|
const state = useState(key, getState);
|
|
|
|
const refresh = () => {
|
|
const value = getState();
|
|
state.value = get(value);
|
|
};
|
|
|
|
return [state, refresh] as const;
|
|
}
|