-
-
Notifications
You must be signed in to change notification settings - Fork 685
Open
Description
I've been using dexie-svelte-query in a Svelte 5 project and in most cases it seemed to work like a charm, but then I stumbled on a situation where it doesn't seem to monitor the underlying data correctly.
I'm rendering an array of attachments based on a live query. The first sample below does not update correctly while the other one (plain liveQuery with $ vars, updates correctly):
Not updating correctly:
const localDraftQuery = stateQuery(
() =>
db.localDrafts.where("conversationId").equals(conversationId).first(),
() => [conversationId]
);
const localDraft = $derived(() => localDraftQuery?.current);
const attachments = $derived(localDraft()?.attachments ?? []);Updating Correctly!:
const localDraft = $derived(liveQuery(() => db.localDrafts.where("conversationId").equals(conversationId).first()));
const attachments = $derived($localDraft?.attachements ?? []);Unfortunatetely, I have no complete repro right now to share.
Related PR: #2116
Source of the svelte-query library: /libs/dexie-svelte-query/src/lib/stateQuery.svelte.ts
Metadata
Metadata
Assignees
Labels
No labels