dev...
This commit is contained in:
@@ -1,20 +1,22 @@
|
||||
import { useCallback } from "react";
|
||||
import { STOKEY_SYNC } from "../config";
|
||||
import storage from "../libs/storage";
|
||||
import { useStorages } from "./Storage";
|
||||
import { STOKEY_SYNC, DEFAULT_SYNC } from "../config";
|
||||
import { useStorage } from "./Storage";
|
||||
|
||||
/**
|
||||
* sync hook
|
||||
* @returns
|
||||
*/
|
||||
export function useSync() {
|
||||
const storages = useStorages();
|
||||
const opt = storages?.[STOKEY_SYNC];
|
||||
const update = useCallback(async (obj) => {
|
||||
await storage.putObj(STOKEY_SYNC, obj);
|
||||
}, []);
|
||||
return {
|
||||
opt,
|
||||
update,
|
||||
};
|
||||
const { data, update } = useStorage(STOKEY_SYNC, DEFAULT_SYNC);
|
||||
return { sync: data, updateSync: update };
|
||||
}
|
||||
// export function useSync() {
|
||||
// const storages = useStorages();
|
||||
// const opt = storages?.[STOKEY_SYNC];
|
||||
// const update = useCallback(async (obj) => {
|
||||
// await storage.putObj(STOKEY_SYNC, obj);
|
||||
// }, []);
|
||||
// return {
|
||||
// opt,
|
||||
// update,
|
||||
// };
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user