本页还没有译文
本页 22 段还没译成한국어,下面显示的是英文原文。LocalStorageCollectionUtils
还没翻译译自英文(tanstack.com)本页 22 段都还没译
Defined in: packages/db/src/local-storage.ts:156
LocalStorage collection utilities type
Extends
Indexable
[key: string]: anyProperties
acceptMutations()
acceptMutations: (transaction) => Promise<void>;Defined in: packages/db/src/local-storage.ts:179
Accepts this Collection's manual mutations in write order and persists them to localStorage. Call it inside the transaction's mutationFn. The transaction's persistence receipt waits for this work even if the caller does not await the returned Promise. Await it when later mutationFn work depends on the storage write.
Parameters
transaction
The transaction containing mutations to accept
mutations
PendingMutation<Record<string, unknown>, OperationType, Collection<Record<string, unknown>, any, any, any, any>>[]
Returns
Promise<void>
Example
const localSettings = createCollection(localStorageCollectionOptions({...}))
const tx = createTransaction({
mutationFn: async ({ transaction }) => {
// Make API call first
await api.save(...)
// Then persist local-storage mutations after success
await localSettings.utils.acceptMutations(transaction)
}
})clearStorage
clearStorage: ClearStorageFn;Defined in: packages/db/src/local-storage.ts:157
getStorageSize
getStorageSize: GetStorageSizeFn;Defined in: packages/db/src/local-storage.ts:158