Created
April 23, 2024 11:59
-
-
Save ryanzec/d5f5d61fe484fabbb6649bfd8afc6459 to your computer and use it in GitHub Desktop.
create store per property of object svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const buildPropertyWritables = <TFormData extends object>(data: TFormData) => { | |
const writables: Record<string, Writable<any>> = {}; | |
Object.keys(data).forEach((key) => { | |
writables[key] = writable(data[key as keyof TFormData]); | |
}) | |
return writables as Record<keyof TFormData, Writable<any>>; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment