Fork me on GitHub
#re-frame
<
2019-07-08
>
jkrasnay15:07:30

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?

lwhorton16:07:48

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

jkrasnay15:07:24

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.

samedhi15:07:46

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.

samedhi15:07:24

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.

shaun-mahood16:07:11

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.

knubie18:07:05

an alternative to storing functions might be to store other events

jkrasnay20:07:55

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!)