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ā€¢11mo ago
what kinda of settings? Probably just one writeable #depends xD
MartynasXS
MartynasXSā€¢11mo ago
well I have some for conditional logic for first render of the ui
b1mind
b1mindā€¢11mo ago
Would probably depend how I'm saving the settings too šŸ˜„
MartynasXS
MartynasXSā€¢11mo 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ā€¢11mo ago
yea should be ok with one writeable
Jochem
Jochemā€¢11mo 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ā€¢11mo ago
I think its a Tauri app
MartynasXS
MartynasXSā€¢11mo 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ā€¢11mo ago
ah, right, forgot that you were working on that
MartynasXS
MartynasXSā€¢11mo 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ā€¢11mo 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
MartynasXSā€¢11mo ago
hmmm
ErickO
ErickOā€¢11mo ago
Booleans for settings bad
b1mind
b1mindā€¢11mo ago
shush
ErickO
ErickOā€¢11mo ago
Baaad
MartynasXS
MartynasXSā€¢11mo ago
why so?
b1mind
b1mindā€¢11mo ago
what you use 1's and 0's xD
ErickO
ErickOā€¢11mo ago
Shuddup
b1mind
b1mindā€¢11mo ago
ayo
ErickO
ErickOā€¢11mo ago
It's called bit flags ok? šŸ˜¤
b1mind
b1mindā€¢11mo ago
function increment() {
$count = $count + 1
}
function increment() {
$count = $count + 1
}
lol this is what I do vs that example >.>;;
ErickO
ErickOā€¢11mo 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ā€¢11mo ago
He has been into state machines and stuff xD
ErickO
ErickOā€¢11mo 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ā€¢11mo ago
Also just cause my mentor does something don't mean I listen >.>;;
ErickO
ErickOā€¢11mo 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ā€¢11mo ago
he also sets font-size: 62.5% and got slammed on twitter for it hahah tweet blew up was so funny
ErickO
ErickOā€¢11mo ago
must've been a bit... joyless hmm the video is about state lol I mean kinda same logic
b1mind
b1mindā€¢11mo ago
yea
ErickO
ErickOā€¢11mo 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
MartynasXSā€¢11mo ago
do you have to know whats in the settings json file if its being parsed and displayed in the UI?
MartynasXS
MartynasXSā€¢11mo ago
its the startup state of these checkboxes basically
ErickO
ErickOā€¢11mo ago
ok the ending made my head hurt but good video I meaaan...code clarity is always nice
MartynasXS
MartynasXSā€¢11mo ago
I Mean sure
ErickO
ErickOā€¢11mo ago
so I gather these are filters
MartynasXS
MartynasXSā€¢11mo ago
Could say that. its more like masking tape it still shows everything just doesnt affect the deselected parts
ErickO
ErickOā€¢11mo ago
wha sure the booleans are fine
MartynasXS
MartynasXSā€¢11mo ago
I mean i can store it as a bit map sure
ErickO
ErickOā€¢11mo 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
MartynasXSā€¢11mo ago
ur the one who brought it up in the first place
ErickO
ErickOā€¢11mo ago
ayo I said it depends on what you were doing
MartynasXS
MartynasXSā€¢11mo ago
aight ā¤ļø
ErickO
ErickOā€¢11mo ago
šŸ˜¤
MartynasXS
MartynasXSā€¢11mo 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
More Posts