Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

svelte 5 sveltekit spa object change detection

$
0
0

I started using Svelte-5 with Sveltekit as a SPA with Firebase.In an update form I like to detect when fields change to show buttons like commit and reset when object props change.

Now I use something like this:

history = $State()let delta = $derived({    title: sectionObj.title,    contra: sectionObj.contra,    exposed: sectionObj.exposed,    vat: sectionObj.vat,    groupIds: JSON.stringify(sectionObj.groupIds.filter((g) => g !== '')),    lookup: JSON.stringify(sectionObj.lookup),    ignored: sectionObj.ignored,    rename: sectionObj.rename,});onMount(() => {    ...    history = delta;});let equal = $derived(isEqual(history, delta));  // lodash

Other sugegstions?


Viewing all articles
Browse latest Browse all 1541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>