-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use svelte rune to update props in frontend reports
For now, this makes the props passed to these components deeply reactive as there is no easy way to opt out of it right now. This might slightly impact performance as all the props are proxified.
- Loading branch information
Showing
2 changed files
with
38 additions
and
14 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** Create a reactive props proxy to allow updating of props. */ | ||
export function updateable_props<T extends Record<string, unknown>>( | ||
raw_props: T, | ||
): [props: T, update: (v: T) => void] { | ||
// TODO: this makes it deeply reactive, which adds unnecessary overhead | ||
const props = $state(raw_props); | ||
return [ | ||
props, | ||
(new_props) => { | ||
Object.assign(props, new_props); | ||
}, | ||
]; | ||
} |
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