Saving Functions as module settings
@wasp I remember you asked about saving functions as settings (which quickly turned into stringifying them IIRC?), did you end up doing something about that ? I am sort of in dire need of the same haaha EDIT I'll thread this to keep the convo focused
9 Replies
In particular, I need to save the Commands for
Commander
, that have several inner functions (looking for an example)I did not, no - but if you were to stringify the function and then
eval(settingString)()
you can at least call itis it just plain
??? I recalled we had to do some processing to it
like rehydrating the function using a new Function(..) and stuff
Yeah,
eval
and new Function
I believe will both workfor ref, this is what I want to save (objects with this shape)
hmm ok, I will play a little bit and report back probably later today 😆
thanks!
@ccjmk gave LeaguePoints™ to @wasp (#6 • 386)
That looks similar to what I found.
https://oprearocks.medium.com/serializing-object-methods-using-es6-template-strings-and-eval-c77c894651f0
I landed here https://stackoverflow.com/a/40876342 looks like the same approach, will give this a try later today! 🙂 this pesky thing called work got in the middle 😆
Stack Overflow
JavaScript - Save object with methods as a string
I've been looking around for a way to do this but can't seem to find anything, I have different configuration objects that I need to save as a text in variables for some processing later on, here i...
In case you were still looking into it Wasp, this is what I did:
Oh it's not really working as expected yet 😦