Fork me on GitHub
#re-frame
<
2019-06-17
>
kingcode01:06:16

thx @gadgly, will check it out! Just started reading on d3, looks quite powerful

kingcode01:06:41

sorry, thx @gadfly

attentive02:06:29

Hey all, how's it going?

attentive02:06:04

I'm a fair way along developing a decent size React Native application using Re-Frame. Broadly happy with the framework (it's certainly nicer than other things I've used in the past)

attentive02:06:57

I feel like I'm starting to find a few pain points now and would be interested to discuss them with people in here who may have advice / similar war stories 🙂

mikethompson03:06:50

@kingcode depending on your needs, you might also want to look at using vega-lite

mikethompson03:06:04

Instead of using d3 directly

mikethompson03:06:03

@attentive if you can describe the problems in the most minimal/distilled way you might well get some good feedback.

4
kingcode03:06:52

Thanks @mikethompson - was considering vega already, didn’t know about oz, will definitely check it out!

mikethompson03:06:38

You might know this already but there is vega and vega-lite. The second is much easier to use and yet more than powerful enough for most circumstances

mikethompson03:06:15

There is also highcharts which some seem to like

kingcode04:06:14

@ mikethomson I need to create a graph for multivariate clustering - sort of plotting dots (data points) in a 2d space with no axis, but the distance b/w dots should be proportional to their respective distances from one another (which I would provide from a distance fn). Also, pretty neat that Vega/lite is built on top of d3.js - I was reading up on that. Thx for your advice.

mac11:06:41

Any idea why I would be getting a re-frame: no :event handler registered for: when I am requiring app.events in core.cljs? This only happens upon start of the app so I expect some kind of race, but not sure how to ensure that handlers are registered before being called other that through require in core.cljs.

mikethompson11:06:59

So the id of the event appears to be blank??

mikethompson11:06:16

Are you doing this (dispatch []) ?

mac11:06:11

@mikethompson Oh, sorry the full text is app.events/add-event-to-log.

mac11:06:32

@mikethompson I mean the error does contain the id.

mac11:06:23

@mikethompson Full text is re-frame: no :event handler registered for: :app.events/add-event-to-log

mikethompson11:06:58

So, you feel that you are dispatching that event before registering.

mac11:06:48

@mikethompson That is how it appears to me, but since I require events in core.cljs, that should not really be possible right?

mac11:06:10

@mikethompson Is there a way to list all registered handlers?

mikethompson11:06:10

No official API, but re-frame.registrar.kind->id->handler is a map ...

mikethompson11:06:23

which has a key :event

mikethompson11:06:01

Who's value is another map which links ids with handlers

mikethompson11:06:12

So ... this will give you all registered event handlers (keys (:event re-frame.registrar.kind->id->handler))

mac12:06:41

@mikethompson Yeah, so the handler is there.

mac12:06:24

@mikethompson Ah, no it is not. Not upon reload. But if I change the calling namespace and trigger a recompile it is there. So it appears it is a race of some sort.

mac12:06:20

@mikethompson In fact :event is nil. So no handlers are there.

mikethompson12:06:05

I'd put a breakpoint in dispatch to find out where this early dispatch is happening

mikethompson12:06:47

Then, at least, you can figure out what is dispatching so early in your startup

mac12:06:31

@mikethompson Sorry for my ignorance but how do I go about setting a breakpoint in that file?

mikethompson12:06:34

When running the application in the browser: 1. press F12 to get devtools up 2. Click on the "Sources" tab 3. Find the cljs file I nominated. 4. Put in a breakpoint 5. Reload you application

mikethompson12:06:39

(I'm assuming are doing dev builds and you have source maps)

mac12:06:49

@mikethompson Got it. It is called from my init-db function.

mikethompson12:06:38

So your init-db function should get called by your main

mikethompson12:06:02

Because by the time you get to executing main, everything is loaded

mikethompson12:06:19

And all events should be registered

mac12:06:12

@mikethompson main ? I have an init in my core.cljs

mikethompson12:06:22

Okay, then that

mikethompson12:06:30

Whatever is your entry point

mac12:06:02

@mikethompson I am dispatching my initialize-db event from init in core.cljs.

kstehn12:06:39

For breakpoints you can also just Use (js-debugger) :)

mikethompson12:06:26

Code is in a library, so adding (js-debugger) is harder

mac12:06:02

@mikethompson But that does not hit the breakpoint, I think because it uses dispatch-sync.

mikethompson12:06:38

So you'll have to set an extra breakpoint

mikethompson12:06:47

I'm afraid I'm off to bed.

mac12:06:10

@mikethompson Thanks for your help, really appreciated.

mac15:06:04

@mikethompson Solved it. There was a def that - indirectly - invoked dispatch in app.db which in turn was being required by core.cljs.