Fork me on GitHub
#re-frame
<
2020-11-27
>
jmckitrick14:11:42

What’s the best approach to a re-frame form edit widget where some of the fields must be rendered from custom objects, like date/time or a money field?

p-himik14:11:15

I don't understand what you mean by "be rendered from custom objects". But maybe you can get some ideas from some of the re-com widgets.

jmckitrick14:11:23

Hmm, ok I’ll take a look.

jmckitrick14:11:07

I’m just referring to js objects that need to be formatted in a form field, since they aren’t simple strings or numbers.

jmckitrick14:11:28

So, when to convert them, where to keep the state, when to convert back, etc.

p-himik14:11:24

I think it's somewhat obvious: > when to convert them Exactly when you need the converted value. > where to keep the state Where you usually keep the state when you have to deal with just strings and numbers. > when to convert back When you need to update the state.

jmckitrick14:11:51

Well, I thought perhaps it would be easier to deal with one format vs another on the js side. The transit format is great for over the wire, but other types might be better for JS side manipulation. Since I'm new to the transit types, I'm still figuring this out....

p-himik15:11:08

Ah, right. Personally, I'm fine with the types that Transit supports. And when I'm not (like it can be with #inst), it's fairly easy to redefine the default read/write handlers to support custom types that you seem as more fit. You don't need to convert the data manually everywhere.