Fork me on GitHub
#re-frame
<
2019-08-21
>
abdullahibra13:08:01

i'm trying to make a simple file upload, briefly the idea is in the input with type file i have on-change fun which will set the file using an event at the app db, and there is another button to submit it, i access the file from db and attach to params and send why couldn't i do this ?

abdullahibra13:08:14

is it possible to save js/File on app-db of reframe ?

oconn14:08:03

@abdullahibra It is possible to store the file in memory in re-frame’s app-db, however I personally would avoid that in my apps because, like functions, they don’t serialize and I prefer re-frame state to be able to be re-hydrated. Also localStorage concerns.

abdullahibra14:08:48

@oconn so you fetch it using getelementbyid method?

oconn14:08:49

Sounds like a form-2 component could hold the file object if you just need a pointer to it right there

abdullahibra14:08:29

i tried to save it at app-db but i got no tag for object

oconn14:08:19

So if you want to store it in re-frame, I would expect that you could dispatch the file object and subscribe directly to it in the component that cares about it.

abdullahibra14:08:33

@oconn can i register cofx for it ?

mccraigmccraig14:08:42

yes @abdullahibra i would generally put a js/File object somewhere else, outside the app-db, perhaps in an atom with an {<id> File} map, then put the <id> in the app-db and retrieve the File where necessary with a cofx

oconn14:08:56

^ yep, I would go with the first approach if no other components / events care about the file, the second if they do.

abdullahibra15:08:06

@oconn @mccraigmccraig i have tried it, but i can not associate to atom file

abdullahibra15:08:10

Error: No protocol method IAssociative.-assoc defined for type cljs.core/Atom: [object Object]

abdullahibra15:08:13

that's how i get the file from input file type

mccraigmccraig15:08:41

an atom is not a map @abdullahibra - you change the contained value with swap! - (swap! attachments assoc (str (.-name file)) file)

danielneal15:08:18

is it possible to use the tracing output of re-frame 10x without starting the devtool. Thinking about react native use case again

mikethompson22:08:22

@danieleneal There are a few layers/sources of the trace re-frame itself is instrumented and produces trace. re-frame-10x is a consumer of this trace Then there's the whole dubux fn-traced instrumentation you can add to your event handlers. re-frame-10x consumes this, if you use the right macros. https://github.com/Day8/re-frame-debux Then finally, re-frame-10x gets drunk on power and does a couple of glorious monkey patch hacks to squeeze even more trace out of reagent It then combines, curates and renders this "total trace" in an epoch-oriented fashion.

mikethompson22:08:04

Hmm. Looking back, I think I misread your question. You are not looking to source trace LIKE re-frame-10x and build another consumer. Instead, you are wondering if re-frame-10x itself can make available the trace it collects for use by another consumer. Ie. re-frame-10x is still part of the solution.

mikethompson22:08:38

My answer for that is unhelpful, sorry: its been a while and I can't remember. Probably. Ultimately, all the raw trace is kept in an atom somewhere.