Charm Questions
I'm not sure if this has been discussed before but I have three questions about charm:
1. What happens if you want to assign nil (undefined) to an atom? Do you have to attach a function that returns nil (or undefined)?
2. What if an atom stores a function? Do you need to chain a function inside a function?
3. What happens if your effect callback uses a dependency conditionally? How will charm know about that dependency if the dependency does not get read from/written to the first time the callback is executed?
Thank you in advance for the help!
18 Replies
cc @LITTENSY
Solution
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Woah, i didn't know luau could differentiate between myAtom(nil) and myAtom()?? wth, is this a new typesolver feature or smth
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
oh my gosh of course, i totally forgot about that lol
also i dont understand what you mean by your third point.
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
does that mean conditional dependencies dont get listened to for changes?
i see
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
(assuming they did not run)
okay so just to be certain: if there is a dependency that is read from/written to conditionally, it is possible that updates to it will NOT cause the effect callback to execute, is that right?
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
i see, okay so do you encourage developers to call atoms at the beginning of the callback at least once if they are run conditionally?
wdym?
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
okay let me write out an example
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
i see, that makes sense
@Tester (Ping in reply pls!)
it recaptures atoms after change
hmm i can kinda see why my example wont really come up as being 'an issue' in the real world
okay thank you so much guys! i rlly appreciate it:)