Skip to content

Conversation

DTCurrie
Copy link
Member

Added a streamQueryKey factory function for both internal use, and to be used to manage queries directly with the query client. For example: for createResourceStream we may want to strictly flush old stream events to avoid accumulating them in the tanstack client and causing memory issues.

Here is a practical example for motion-tools:

	$effect.pre(() => {
		if (changeStream.current?.data === undefined) return

		const events = changeStream.current.data.filter((event) => event.transform !== undefined)
		if (events.length === 0) return

		worker.postMessage({ type: 'change', events })

		// clear the stream data to prevent event accumulation and memory issues
		queryClient.setQueryData(streamQueryKey(partID(), resourceName(), 'streamTransformChanges'), [])
	})

@DTCurrie DTCurrie requested a review from mattmacf98 September 17, 2025 20:37
@DTCurrie DTCurrie self-assigned this Sep 17, 2025
Copy link

changeset-bot bot commented Sep 17, 2025

🦋 Changeset detected

Latest commit: 79604ac

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@viamrobotics/svelte-sdk Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@DTCurrie DTCurrie merged commit 6b6951c into main Sep 18, 2025
4 checks passed
@DTCurrie DTCurrie deleted the export-stream-query-key-factory branch September 18, 2025 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants