Fork me on GitHub
#re-frame
<
2019-05-27
>
tomaas09:05:45

hi, re-frame template app lets you use secretary/dispatch! "my-route". However this does not change the url in the browser? What should i use for this?

dangercoder12:05:32

@tomaas If you want to keep on using secretary I would combine it with https://github.com/venantius/accountant to solve that issue.

lepistane13:05:50

or just use kee-frame?

dangercoder13:05:08

Yes, if he doesn't want to abandon secretary that is a fine choice.

rgm16:05:43

@tomaas I’ve messed with secretary + accountant and bidi + pushy, and it never really clicked for me at all until I came across the reitit.frontend.easy example for re-frame: https://github.com/metosin/reitit/blob/master/examples/frontend-re-frame/src/cljs/frontend_re_frame/core.cljs

ts150318:05:40

Hello guys. I have some problem with specing the event handlers in re-frame. I’m doing something like this

(defn my-event
  [db [value]]
  ...)

(s/fdef my-event
        :args (s/cat :db :app/state
                     :event string?)
        :ret :app/state)

(rf/reg-event-db
 :my-event
 [rf/trim-v]
 my-event)
So here should be an error because event vector is not a string, but I didn’t get an error What I’m missed?

lilactown19:05:14

1. are you calling clojure.spec.test.alpha/instrument?

lilactown19:05:01

2. you’ll need to make sure you pass in my-event to reg-event-db after you have instrumented it

ts150320:05:08

Thanks @lilactown I’ve made a clojure.spec.test.alpha/instrument call But why I need to pass my functions after I instrument it. Do re-frame change it somehow?

ts150320:05:26

Btw it works if I did it in order you’ve mentioned )) But I can’t figure out how to set up this order automatically I’m using shadow-cljs and I have a :after-load function which calls the clojure.spec.test.alpha/instrument function but this seems to be the wrong order

thheller20:05:51

@ts1503 instrument is a macro relying on "previous" compiler information. so it must always be called after all other code has been compiled

thheller20:05:16

the easiest way to achieve is would be to have the namespace that has the instrument call depend on all the others

lilactown20:05:42

Re-frame captures the reference to the function

lilactown20:05:12

So when instrument replaced the function with the instrumented version, re-frame still has a reference to the old one

thheller20:05:36

oh yeah that too 🙂

lilactown20:05:12

You might be able to use a var quote

lilactown20:05:38

Or register a function that calls your specced function

ts150320:05:25

Thank you guys! It’s little bit more complicated than I expected ))

lilactown20:05:54

Yeah. This is an edge case that instrument doesn't handle very well

ts150320:05:27

so basically I need to separate phases of defining handlers functions and calling the rf/reg-event-db with instrumented versions of this functions

kenny20:05:10

@sergey.tkachenko I have a re-frame wrapper I've been messing around with for a while. To work around that issue, I changed the way all the reg-* functions work -- they only get registered after an init! function has been called. See https://github.com/ComputeSoftware/re-structure/blob/2a8b6a2d28b92de8bbba13b9ba591fd674dc65d0/src/re_structure/core.cljc#L18-L22 and the example init here: https://github.com/ComputeSoftware/re-structure/blob/2a8b6a2d28b92de8bbba13b9ba591fd674dc65d0/examples/basic/core.cljs#L23-L24. Not sure if I actually like this idea or not. Haven't had much time to put thought into this.

ts150320:05:19

Thanks @kenny will try your approach