Fork me on GitHub

Hi folks, in my Re-frame app I’m thinking of enforcing the rule that app DB should never contain functions or other things that prevent it from serializing it to, say, Transit. My idea is that some day I may wish to send the app DB to the server so I can re-create user errors in my own environment. Has anyone done this? Is it a reasonable thing to shoot for?


absolutely. its always ideal to only keep data in the db. as soon as you introduce functions or refs you have introduced a lot of complexity


Also, it kinda feels like I should follow the same convention for my events, but I don’t have as good a use-case for that.


I am almost more focused on having realized values rather than functions (with potential closures) in applications because of the human element. I just can't reason about a function, I can reason about a value.


With that said, seems like one of those things that is "A good idea in general, use common sense in terms of when to break it". tldr; I wouldn't make it an invariant (with add-watch), but might put it into your coding standard.


I've had a few cases where functions in my app-db made sense, but I make sure to keep them in a separate area from the values.


an alternative to storing functions might be to store other events


Thanks all. I think @samedhi’s point of reasoning about values is bang on, even without my use-case. (Great tip about add-watch too!)