Fork me on GitHub

Please someone tell me whether app-db can contain non-literal values such like file objects embedded in <input type=”file”> ?


@akiroz Thank you. For maintaining replay-ability, I'd thought app-db value should be serializable one.


@knjname It’s just a hash map. I don’t think re-frame does any serialization.


Although reading your reply… I expect you’re right. If you want to be able to trace the whole thing, then chances are you’d want the message parameters to be easily serializable.


@knjname we stick strictly to the "only data" rule. Only data in app-db. Only data in events


But, yes, file objects are possible


@mikethompson Definitely reasonable and what we do as well. But I thought it was important to clarify there’s no magic going on.


What if we want to avoid storing such dirty objects in app-db, how can it be? In my case, an SPA user can choose a file :on-change #(dispatch [:store-file (get-file %)]) , and upload the file when pushing upload button #(dispatch [:upload-file]). (Maybe in this simple case, you would recommend me to use local state in the first place.)


Are there any docs or blog posts that talk about integrating re-frame applications inside of other re-frame applications? I have a hefty reagent component (a data table with lots of features) that's powered by re-frame that I'd like to offer to myself as a dependency in another re-frame project. When the component is required I'd like it to use the parent application's app-db where lots of data is already available. Before I start chasing rabbits, is there a best practice for this?


I'd also like to dispatch events internal to the embedded re-frame application from the parent application. 🙂


@knjname I have file upload with re-frame in my last project, and I keep the filename in a local ratom. So that on-change acts only on the ratom, and on-click on the submit button I just dispatch [:upload-file file] and do it with cljs-ajax in a handler


Are there any docs on when and how to use the 2nd parameter to the inputs functions supplied to re-frame/reg-sub? I know the todomvc example says it's an advanced feature, but it would be nice to understand what kinds of things it can be used for.