Webapp settings

Would you have settings in a json object in a single store or a separate store writable for each setting?
44 Replies
b1mind
b1mindā€¢2y ago
what kinda of settings? Probably just one writeable #depends xD
MartynasXS
MartynasXSOPā€¢2y ago
well I have some for conditional logic for first render of the ui
b1mind
b1mindā€¢2y ago
Would probably depend how I'm saving the settings too šŸ˜„
MartynasXS
MartynasXSOPā€¢2y ago
{
"PreferredMode": "linear",
"IgnoreBW": true,
"RitoBinPath": "C:\\custom skins\\ritobin\\ritobin_cli.exe",
"RememberTargets": false,
"Targets": [
false,
false,
false,
false,
true
],
"Regenerate": true
}
{
"PreferredMode": "linear",
"IgnoreBW": true,
"RitoBinPath": "C:\\custom skins\\ritobin\\ritobin_cli.exe",
"RememberTargets": false,
"Targets": [
false,
false,
false,
false,
true
],
"Regenerate": true
}
b1mind
b1mindā€¢2y ago
yea should be ok with one writeable
Jochem
Jochemā€¢2y ago
massive massive alarmbells at a .exe in frontend code please tell me that's only used to generate a command the user can then copy paste?
b1mind
b1mindā€¢2y ago
I think its a Tauri app
MartynasXS
MartynasXSOPā€¢2y ago
its a tauri app indeed i use the .exe for conversion actions as im not into writing binary magic in js its not my exe also
Jochem
Jochemā€¢2y ago
ah, right, forgot that you were working on that
MartynasXS
MartynasXSOPā€¢2y ago
I would prefer to handle it on my own, but its a project for another day so followup question, so would you subscribe to whole object in route level and pass specific parts of it as a prop to components or subscribe to the store in each component individually
b1mind
b1mindā€¢2y ago
I would use $ and in comps Whole point of the global context is not to prop drill (least one point) Pretty much always use the auto-sub syntax xD https://learn.svelte.dev/tutorial/auto-subscriptions (click solve) just so clean šŸ„° oh they do use the methods in those xD I just $store = value or $store.thing = value
MartynasXS
MartynasXSOPā€¢2y ago
hmmm
ErickO
ErickOā€¢2y ago
Booleans for settings bad
b1mind
b1mindā€¢2y ago
shush
ErickO
ErickOā€¢2y ago
Baaad
MartynasXS
MartynasXSOPā€¢2y ago
why so?
b1mind
b1mindā€¢2y ago
what you use 1's and 0's xD
ErickO
ErickOā€¢2y ago
Shuddup
b1mind
b1mindā€¢2y ago
ayo
ErickO
ErickOā€¢2y ago
It's called bit flags ok? šŸ˜¤
b1mind
b1mindā€¢2y ago
function increment() {
$count = $count + 1
}
function increment() {
$count = $count + 1
}
lol this is what I do vs that example >.>;;
ErickO
ErickOā€¢2y ago
wait b1 u fricker you shushing me when your mentor just did a video on this 10 days ago it says smh you fricking frick
b1mind
b1mindā€¢2y ago
He has been into state machines and stuff xD
ErickO
ErickOā€¢2y ago
Joy of Code
YouTube
Do This Instead Of Representing State With Booleans
Learn how to go from using booleans to represent state to writing a reducer and a simple state machine in Svelte to using XState to avoid impossible states and have more confidence your code works as expected. šŸ‘‰ļø Support ā–¶ļø YouTube Membership https://youtube.com/@joyofcodedev/join šŸ”“ Patreon https://www.patreon.com/joyofcode šŸ‘‰ļø Links: XState...
b1mind
b1mindā€¢2y ago
Also just cause my mentor does something don't mean I listen >.>;;
ErickO
ErickOā€¢2y ago
I agree with no booleans, and enums instead (or at least the shitty JS version of an enum) dunno about a state machine tho
b1mind
b1mindā€¢2y ago
he also sets font-size: 62.5% and got slammed on twitter for it hahah tweet blew up was so funny
ErickO
ErickOā€¢2y ago
must've been a bit... joyless hmm the video is about state lol I mean kinda same logic
b1mind
b1mindā€¢2y ago
yea
ErickO
ErickOā€¢2y ago
it all depends on what you're doing here targets is my main issue there wtf is targets, what does that array represent who knows, not me just checking the settings so I'll have to look at the function to figure it out
MartynasXS
MartynasXSOPā€¢2y ago
do you have to know whats in the settings json file if its being parsed and displayed in the UI?
MartynasXS
MartynasXSOPā€¢2y ago
its the startup state of these checkboxes basically
ErickO
ErickOā€¢2y ago
ok the ending made my head hurt but good video I meaaan...code clarity is always nice
MartynasXS
MartynasXSOPā€¢2y ago
I Mean sure
ErickO
ErickOā€¢2y ago
so I gather these are filters
MartynasXS
MartynasXSOPā€¢2y ago
Could say that. its more like masking tape it still shows everything just doesnt affect the deselected parts
ErickO
ErickOā€¢2y ago
wha sure the booleans are fine
MartynasXS
MartynasXSOPā€¢2y ago
I mean i can store it as a bit map sure
ErickO
ErickOā€¢2y ago
eh it'd make sense if you had a lot of them and wanted to save some memory but it's 5 of 'em you're good
MartynasXS
MartynasXSOPā€¢2y ago
ur the one who brought it up in the first place
ErickO
ErickOā€¢2y ago
ayo I said it depends on what you were doing
MartynasXS
MartynasXSOPā€¢2y ago
aight ā¤ļø
ErickO
ErickOā€¢2y ago
šŸ˜¤
MartynasXS
MartynasXSOPā€¢2y ago
red underline everywhere smh smh I guess i should have placeholder settings in store instead of empty object
Want results from more Discord servers?
Add your server