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

Did you find this page helpful?