re-frame

BuddhiLW 2023-08-11T15:43:21.814629Z

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)}))))

wevrem 2023-08-11T15:45:50.599929Z

One way:

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

wevrem 2023-08-11T15:47:06.975179Z

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

✅ 1
BuddhiLW 2023-08-11T15:50:15.627749Z

Thanks a lot!

Drew Verlee 2023-08-11T19:59:13.532419Z

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 Verlee 2023-08-11T20:01:16.185979Z

potentially relevant SO https://github.com/day8/re-frame-10x/issues/269

Drew Verlee 2023-08-11T20:06:53.621259Z

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....

Kimo 2023-08-12T01:11:50.078529Z

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?

👀 1
Drew Verlee 2023-08-12T01:24:20.775429Z

I'll take a look. Thanks!