เครื่องมือจัดเก็บข้อมูล
ตรวจสอบว่ามี named state ถูกบันทึกหรือไม่ และค้นหาข้อมูลจริงเกี่ยวกับ storage และคีย์ที่บันทึก.
hasRxState
ตรวจสอบว่ามีค่าที่ระบุในตำแหน่งนั้นหรือไม่ โดยระบุชื่อและตัวเลือก storage เป็น boolean.
const exists = await hasRxState("count", {
storage: "sessionstorage",
});
// booleanfindRxStateStorages
หากส่งเพียงชื่อ จะส่งคืน backend storage ที่ตรวจสอบแล้วในรูปแบบอาร์เรย์โดยไม่มีการซ้ำกัน ค่าที่บันทึกด้วย auto จะถูกส่งคืนเป็น backend ที่เลือกจริง.
const storages = await findRxStateStorages("count");
// RxStateResolvedStorage[]
// 예: ["indexeddb", "localstorage", "sessionstorage"]getRxStateStorageInfo
ส่งคืนตำแหน่งที่บันทึกที่ตรวจสอบแล้วเสมอในรูปแบบอาร์เรย์ หากชื่อเดียวกันมีอยู่ในหลาย storage หรือการตั้งค่าชื่อ/storeName/keyPrefix ที่แตกต่างกัน จะส่งคืนเป็นรายการแยกต่างหาก หากส่งตัวเลือก storage เป็นพารามิเตอร์ที่สอง จะสามารถค้นหาตามเงื่อนไขนั้นได้.
const infos = await getRxStateStorageInfo("count");
const indexedDbInfos = await getRxStateStorageInfo("count", {
storage: "indexeddb",
});
// RxStateStorageInfo[]interface RxStateStorageInfo {
key: string;
storageKey: string;
fullKey: string;
storage: RxStateResolvedStorage;
name: string;
storeName: string;
keyPrefix: string;
}storageKey คือ item key ที่ส่งไปยัง storage และ fullKey คือคีย์ทั้งหมดที่สามารถตรวจสอบได้จาก backend ที่แสดงคีย์แบบแบนเหมือน localStorage. storage จะส่งคืนเป็น backend ที่แท้จริงไม่ใช่ auto.
ทดสอบการทำงานจริง
สามารถบันทึกคีย์ทดสอบเดียวกันในหลาย storage โดยใช้ปุ่มด้านล่างและตรวจสอบค่าที่ส่งคืนจากสาม API ได้ทันที.
บันทึกค่าทดสอบ
หลังจากบันทึกชื่อเดียวกันในหลาย storage สามารถตรวจสอบค่าที่ส่งคืนจริงจากสามยูทิลิตี้ได้.
ยังไม่ได้ดำเนินการ.
เครื่องมือจัดเก็บข้อมูล Reducer
Reducer ยังมี hasRxReducer, findRxReducerStorages, getRxReducerStorageInfo ในลักษณะเดียวกัน.
await hasRxReducer("cart", { storage: "sessionstorage" });
await findRxReducerStorages("cart");
await getRxReducerStorageInfo("cart");
await getRxReducerStorageInfo("cart", { storage: "indexeddb" });