Fork me on GitHub
#re-frame
<
2017-03-02
>
pandeiro00:03:55

I hit an issue where trying to clear handlers broke the ability to reload my application

pandeiro00:03:11

I was using (re-frame.registrar/clear-handlers)

pandeiro00:03:39

Mostly just to avoid the ton of warning output about handlers and subs being overwritten -- there was no other functional reason to clear them

pandeiro00:03:47

But was I doing it wrong?

pandeiro00:03:09

The app broke when in the reload cycle, it called (dispatch-sync [:init]) again

dragoncube01:03:14

question regarding re-frame-async-flow-fx: why events in rules specified as keywords (event ids) but full event vectors?

dragoncube01:03:54

use case: I need to do 10 sequential http puts which differs only in one field in payload (passed as event parameter), and once those succeed do some other http put

caryfitzhugh16:03:34

@campeterson for login redirects, I wrote a macro that wrapped my defroutes, to check for the current-user and redirect to "/" the "/" redirect handles it from there.

(defmacro user-route
  [name path let-expr & body]
  `(secretary.core/defroute ~name ~path ~let-expr
     (let [cu# (re-frame.core/subscribe [:current-user])]
      (if (deref cu#)
        (do ~@body)
         (accountant.core/navigate! (str "/?return-to=" ~path))))))
does that help much?

caryfitzhugh16:03:05

since it's all client-side, redirecting to "/" and then letting that route do auth / etc seemed all gain and no pain 🙂

joshkh16:03:55

i have an effect that fetches data from a server, and naturally if i run it over and over the latest response isn't always the latest requests. since my API library returns channels i can store the channels in app-db and close them whenever the event fires that dispatches the effect...

joshkh16:03:10

but is closing a channel in an event considered impure?

joshkh16:03:06

for example:

(reg-event-fx
  :someevent
  (fn [{db :db}]
    (let [new-request (http-response-channel)]
      {:db             (-> db
                           (update-in [:some :location] close!)
                           (assoc-in [:some :location] new-request))
       :my-http-effect {:on-success        [:save-results]
                        :chan-to-take-from new-request}})))