Fork me on GitHub
#re-frame
<
2023-08-11
>
BuddhiLW15:08:21

Hey! I have a question related to redirecting the browser to a url outside my application. This will happen through a dispatch function. The function is called :route-changed the handler when equal to :aporte-no-ppi and :saiba-mais will redirect. The default is to use the inside router of the SPA. How would :http/redirect look like? I don't know how to write a function to redirect to external urls.

(rf/reg-event-fx
 :route-changed
 (fn [{nav :db} [_ {:keys [handler route-params]}]]
   (let [nav              (assoc nav :pagina-ativa handler)]

     (case handler
       :aporte-no-ppi {:db (assoc nav :pagina-ativa handler)
                       :dispatch [:http/redirect :aporte-no-ppi]}
       :saiba-mais  {:db (assoc nav :pagina-ativa handler)
                     :dispatch [:http/redirect :saiba-mais]}
       {:db               (assoc nav :pagina-ativa handler)}))))

wevrem15:08:50

One way:

(rf/reg-fx
 :http/redirect
 (fn [loc] (set! (.-href js/location) loc)))

wevrem15:08:06

Actually, that is an effect handler, not an event, but you get the idea.

1
BuddhiLW15:08:15

Thanks a lot!

Drew Verlee19:08:13

When i load reframe10x i get a number of warnings that i assume happen because my version of reagent isn't matching what reframe wants.

Warnings in Library Code:
 Wrong number of args (2) passed to reagent.impl.component/get-wrapper
 Use of undeclared Var reagent.impl.component/component-name
 Wrong number of args (2) passed to reagent.impl.component/do-render
 Wrong number of args (2) passed to reagent.impl.component/do-render
 Use of undeclared Var reagent.impl.component/component-name
 Use of undeclared Var reagent.impl.component/component-name
What would you do to solve this? • update reagent - risk, lots of things in the app might break • fix blah bc that's the real problem... • use a different version of re-frame10x • don't use re-frame 10x bc blah

Drew Verlee20:08:53

looks like i can update my apps reagent or drop down to 10x version 0.7. that's what ill do for now... to the past....

Kimo01:08:50

Hey, it would help to know what versions of 10x and reagent you tried. Do you think the https://github.com/day8/re-frame-10x#compatibility-matrix is still accurate?

👀 2
Drew Verlee01:08:20

I'll take a look. Thanks!