Fork me on GitHub
#re-frame
<
2018-05-21
>
shakdwipeea09:05:59

I am running into this error:

clojure.lang.ExceptionInfo: re-frame: router state transition not found. :scheduled :finish-run {:fsm-state :scheduled, :trigger :finish-run}
I am trying to run sth like
(doseq [i (range 1 10000)]
  (rf/dispatch [:test i]))
Note that I am running this in clojure and not clojurescript.

deg11:05:58

@mikethompson The "triangles not working" problem happened to me again just now. Clearing Application's Local Storage and refreshing was enough to fix the problem.

deg11:05:25

I'm not sure exactly what triggered the problem, but here are some clues: 1) Like last week, it came together with the error of js/window.open returning null 2) This happened when I restarted the app after several days away. So, possibly, it was caused by one of: a) sitting idle for a while (three days) and/or b) forcibly closing and then restarting the cider buffers in emacs c) and/or opening a new browser tab for the app

Bravi12:05:07

thought I’d ask here as well. I’m getting a circular dependency error and cannot figure out how to solve it. so I have routes.cljs

(:require [app.events :as events]) ;; importing events here

(defroute projects "/projects" []
  (re-frame/dispatch [::events/set-active-page {:page :projects}]))
and I have events.cljs
(:require [app.routes :as routes]) ;; importing the above file here

(re-frame/reg-event-db
 ::get-project-success
 (fn [db [_ {project :data}]]
   (-> db
       (assoc-in [:loading :project] false)
       (assoc :active-project project
              :page-title (:title project)
              :breadcrumb [{:label "Projects"
                            :path (routes/projects)} ;; and using it here
                           {:label (:title project)}]))))
@nenadalm recommended to use :app.events/set-active-page in my routes.cljs instead and to remove the import of events module. This works, but I was wondering if there’s another way to deal with this?

deg14:05:08

@mikethompson The problem has occurred twice more. I can't yet see a clear pattern, though it seems to only occur a while after the last time I looked at the window...

flowthing17:05:31

So I have an app-db with a set of students, and every student has a set of grades. When I delete a student, I'd like to ensure that that student's grades are deleted, too. What's the "correct" way to do that with re-frame? I could do something like this:

{:on-click #(do (re-frame/dispatch [:student/delete student])
                           (re-frame/dispatch [:student/delete-grades student]))}
But I'd like the callsite not to have to worry about deleting the grades. I could use a reg-event-fx that uses dispatch-n to dispatch the deleting events, but I'm only operating on the app-db, so that doesn't seem quite right, either.

jcthalys17:05:44

I thing you could {:dispatch-n [[:student/delete-grades student] [:student/delete student]])} or on the event-fx of successfully deleted grades call a dispatch to the [:student/delete student]

flowthing18:05:39

That should work, but they'd then be effect handlers (fx) instead of event handlers (db). I was basically wondering whether there's something like :dispatch-n for reg-event-db.

mikethompson17:05:31

@shakdwipeea can you file a bug report with as much info as you can please.

mikethompson17:05:41

@bravilogy I'd look in "External Resources" in /doc at the various existing apps to see how they do it.

mikethompson17:05:19

@deg thanks for trying to track this down @danielcompton ^^^

mikethompson17:05:45

@flowthing avoid the temptation to think of a dispatch like you would a function call. A dispatch should happen in response to an event. I think you need to write a function called remove-student which knows what the two steps are. Then call than from the event handler.

flowthing18:05:54

@mikethompson Right, that makes sense. I'll do that. Thanks!

flowthing18:05:30

Hmm... my app-db/interceptor setup complicates the matter somewhat. I currently have things set up so that for every db event, only the updated branch of the app-db is validated against specs and stored in local storage. But this operation updates two branches (`:students` and :grades), so it won't work. I think I'll need to adjust things so that validation and local storage updates always happen for the entire app-db.

danielcompton20:05:50

@deg do you have the external window open, or the main panel?