Fork me on GitHub
#re-frame
<
2016-02-04
>
heeton21:02:06

Hey everyone. I’m trying to debug something, how do you check the current app-state from the brepl? I’m having trouble finding out any way to do this, and I bet it’s stupidly simple 😛

danielcompton21:02:18

@heeton

(in-ns 're-frame.db)
@app-db

danielcompton21:02:39

however there’s some other debugging methods in https://github.com/Day8/re-frame/wiki

danielcompton21:02:53

that I find better than using a REPL

heeton21:02:05

@danielcompton: I knew it’d be something like that 😛 Thanks a lot!

heeton21:02:22

I’m checking out some of the more advanced tracing stuff too. I just had an issue with data-at-rest that I wanted to debug

heeton22:02:40

Is there a way to overload event handlers? E.g. here’s a “buy” function - https://gist.github.com/heeton/757cc24be75838caea50 - I’d like to have a default amount of 1 if the event dispatch doesn’t specify an amount to buy

heeton22:02:30

I know the basic clojure way of functions with different arity, but not if it’s nested parameters like [app-state [_ item …]]

yenda22:02:55

heeton have you tried not providing an extra argument to the dispatch ?

yenda22:02:27

I can't test right now but I think that item will be nil so you can just put a condition like nil?

heeton22:02:26

@yenda: hrmmm, yep, thanks

yenda22:02:43

does it work ?

yenda22:02:41

yeah that's better 😄

heeton22:02:08

@danielcompton: amazing, thankyou (again)!

heeton22:02:47

@danielcompton: not sure :or applies to vector parameters (like [_ item count]), just maps?

jaen22:02:33

@heeton: just checked, it doesn't work:

boot.user=> (let [[a [b c d :or {b 2 c 3 d 4}]] [1 [2 3 4]]]
       #_=>   (str "a=" a " b=" b " c=" c " d=" d))
"a=1 b= c= d="
Also replied over at #C03S1KBA2 if that's helpful.

heeton22:02:24

@jaen: thanks a lot, I didn’t spot it at first without the @

gregg22:02:35

@simax99: The way you pass a custom keyboard handler to re-com components is by setting the :attr argument:

:attr {:on-key-press (handler-fn (case (.-which event)
                                   27 (reset! showing? false)
                                   nil))}
However in this case, there is no external access to the atom that controls the state of the [datepicker-dropdown] popover so you're stuck, I'm afraid. If this is really important, feel free to a) add an Issue to the Github repo or b) add a Pull Request.