Fork me on GitHub

I want to log the last x events to my app-db, to include in a crash report


I originally wrote an interceptor


(def log-events
    :id :debounce
    :before (fn [context]
              (let [db (get-in context [:coeffects :db])
                    event (get-in context [:coeffects :event])
                    log (get-in db db-path [])
                    new-log (cond-> (conj log event)
                              (= (count log) max-events) (subvec 1))]
                (assoc-in context (into [:coeffects :db] db-path) new-log)))))


But this is not capturing all events - for example those dispatched and handled by async-flow


What would be the correct approach?


I've thought of using add-post-event-callback, but that wouldn't have access to the db


Hi everyone! I have an issue and don’t know how to solve it. I have two fields in app db and an event that fires a request using data from those two fields. I want to fire a request every time when one of those fields is updated. It should be something like

  (fn {db :db} [_ new-value])
    {:db (assoc db new-value)
     :dispatch [:fire-request]})

  (fn {db :db} [_ new-value])
    {:db (assoc db new-value)
     :dispatch [:fire-request]})

 (fn [{db :db} [_ _]]
   {:http-xhrio {:field1 (:field1 db)
                 :field2 (:field2 db)})
But as soon as event order is undetermined I get nils or previous values from db in :fire-request event. Is there any reliable way to update db first and than send a request?


@achikin That should work. The db will be updated synchronously with the event and the dispatch would go on to a queue to be handled later so it would have the new DB.


Are you sure that the :fire-request event has a nil :field1 if it was dispatched from the :update-field1 event?


It is possible that :fire-request would happen before both fields are processed


Let me try. I got that from my collegue who stated that he gets nil/previous value in the handler.


@kasuko, yes you’re right the order of updates is determined. Is it stated somewhere in the documentation?


Hi all, I'm trying to use a react lib in my re-frame project ( but I don't understand how to mimic the code in the snippet below:


I tried with a [:span ... but the tag name is merged with its content. like [:span "bla"] becomes spanbla. Any idea about what I am missing?


try to wrap it into (reagent.core/as-element)


@l1sp3r @sandbags: FWIW, I tried using re-frame-datatable, and found it incomprehensible and gave up… I ended up rendering tables by hand, which turned out to be very easy. (Not quite relevant to your question, but wanted to share my experiences…) OTOH, if you actually got it working, I’d love to see how you did it! 🙂


@genekim i know i found the instructions a little vague on a couple of points when i used it, but it wasn't too bad and the results are very useful


Wow! Cool, @sandbags — congrats on getting it running! Thanks!


@sandbags: can you share the db.cljs (or whatever) that you’re using re-frame-datatable to render? I couldn’t ever figure out how to bind the library correctly to my data. Thx!


@genekim my db looks like {:contacts [{:gn "Matt" :ln "Mower" :em "<mailto:[email protected]|[email protected]>" :co "Mower/Valdemarin" :ti "Managing Partner" :ke 0 :rt "Blah"} ...]}


@genekim ^^^ that's the :results subscription which is referenced in dt-results-table as [:results] and the source of the data