Fork me on GitHub
#re-frame
<
2021-03-17
>
zendevil09:03:29

I have a question about the order in which effects are executed. Suppose I have a reg-event-fx that’s returning the following map:

{
    :uploader->body [(:video-body cofx) (:_id db)]
    :video->body [(:video-body cofx) (:video db)]
    :thumbnail->body [(:video-body cofx) (:thumbnail db)]
    :title->body [(:video-body cofx) (:title db)]
    :description->body [(:video-body cofx) (:description db)]
    :address->body [(:video-body cofx) (:address db)]
    :date->body [(:video-body cofx) (:date db)]

    :db (assoc db :uploading-progress true
               :upload-error false)
    :http-xhrio {:method :post
                 :progress-handler #(dispatch [:upload-progress %])
                 :uri (str server-uri "/api/upload-video")
                 :body (:video-body cofx)
                 :on-success [:upload-success navigation]
                 :on-failure [:upload-error navigation]
                 :format (json-request-format)
                 :response-format (raw-response-format)}
    }
In what order are the effects executed? Is the order undefined? Is there a way to enforce order?

zendevil09:03:19

How do I make sure that the effects

:uploader->body [(:video-body cofx) (:_id db)]
    :video->body [(:video-body cofx) (:video db)]
    :thumbnail->body [(:video-body cofx) (:thumbnail db)]
    :title->body [(:video-body cofx) (:title db)]
    :description->body [(:video-body cofx) (:description db)]
    :address->body [(:video-body cofx) (:address db)]
    :date->body [(:video-body cofx) (:date db)]
happen before the http-xhrio request?

p-himik09:03:34

Use the :fx effect that accepts a vector of effects that are executed in order. It's documented.