Webapp settings
Would you have settings in a json object in a single store or a separate store writable for each setting?
44 Replies
what kinda of settings?
Probably just one writeable
#depends xD
well I have some for conditional logic for first render of the ui
Would probably depend how I'm saving the settings too š
yea should be ok with one writeable
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?
I think its a Tauri app
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
ah, right, forgot that you were working on that
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
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
hmmm
Booleans for settings bad
shush
Baaad
why so?
what you use 1's and 0's
xD
Shuddup
ayo
It's called bit flags ok?
š¤
lol this is what I do
vs that example >.>;;
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
He has been into state machines and stuff xD
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...
Also just cause my mentor does something don't mean I listen >.>;;
I agree with no booleans, and enums instead (or at least the shitty JS version of an enum)
dunno about a state machine tho
he also sets font-size: 62.5%
and got slammed on twitter for it hahah tweet blew up was so funny
must've been a bit... joyless
hmm the video is about state lol
I mean kinda same logic
yea
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
do you have to know whats in the settings json file if its being parsed and displayed in the UI?
its the startup state of these checkboxes basically
ok the ending made my head hurt but good video
I meaaan...code clarity is always nice
I Mean sure
so I gather these are filters
Could say that. its more like masking tape
it still shows everything just doesnt affect the deselected parts
sure the booleans are fine
I mean i can store it as a bit map sure
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
ur the one who brought it up in the first place
ayo
I said it depends on what you were doing
aight
ā¤ļø
š¤
red underline everywhere smh smh
I guess i should have placeholder settings in store instead of empty object