Fork me on GitHub
#re-frame
<
2018-07-31
>
chrishacker00:07:00

I am trying to use re-frame-debux with re-frame-10x. I spent a couple of hours getting it set up and playing with it but can't get re-frame-debux to work. I'm hoping someone will recognize the error messages and be able to tell me the obvious thing I've missed. We have been using re-frame for almost two years (love it) and I just circled back around to checking out re-frame-10x. I've checked the prereq's and versions - all good: clj 1.8 and cljs 1.9.946 I've got the dependencies set up with the two libs. tracing in :project/dev :dependencies and tracing-stubs in production :dependencies. cljsbuild :compiler settings

:preloads [day8.re-frame-10x.preload]
:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true
                             "day8.re_frame.tracing.trace_enabled_QMARK_" true}
If I try to add [day8.re-frame.tracing :refer-macros [fn-traced defn-traced]] to my handlers.cljs file as :require and then use either of the macros, figwheel fails to compile with Could not Analyze ... Analysis Error targeted at the first use of the macro. If I instead add [day8.re-frame.tracing :refer [fn-traced defn-traced]] to in :require-macros, figwheel will compile the code, but I get a bunch of warnings and the app throws errors when I try to load it in the browser
WARNING: Use of undeclared Var day8.re-frame.tracing/is-trace-enabled? at line 39 src/st/handlers.cljs
WARNING: No such namespace: debux.dbgn, could not locate debux/dbgn.cljs, debux/dbgn.cljc, or JavaScript source providing "debux.dbgn" at line 39 src/st/handlers.cljs
WARNING: Use of undeclared Var debux.dbgn/dbgn at line 39 src/st/handlers.cljs
Successfully compiled "target/cljsbuild/public/js/app.js" in 71.553 seconds.
Any idea what I'm doing wrong?

zalky06:07:11

In case anyone runs into a similar problem to what I outlined above, after some digging it appears that any kind of frequent tracing or polling wreaks havoc on re-frame-10x and makes it unusable (I also tried and event based approach using :dispatch-later with similar results). Unfortunately the trace/event filtering in re-frame-10x appears broken. Using core.async helped side-step the tracing altogether.

heyarne10:07:22

is there an example for client-side routing with permission checks that i could follow? i've been trying to roll my own but i keep messing it up

heyarne10:07:31

the flow i'm trying to has login / remember me functionality with remote authentication, and when a user accesses some routes it should be checked whether they are logged in or not. at the moment i have a race condition between the remember me functionality and setting credentials in the router / permission checks. i've looked into async-flow-fx but it doesn't feel right

heyarne11:07:38

i'm getting warnings no handler registered for effect "event" in my console. what should i make of that?

manutter5112:07:44

Sounds like you might have a line of code somewhere that calls (re-frame.core/dispatch [event])?

heyarne12:07:53

oh, really? i thought i should be looking for {:event [...]} which i didn't find

manutter5112:07:29

Actually now that I look again (and have had a bit more coffee), that’s saying no handler registered for effect, so something is trying to get an effect handler for the value event

manutter5112:07:11

so maybe a reg-event-fx handler somewhere is returning {:db (some-db-value) event [:some-event]} instead of {:db (some-db-value) :dispatch [:some-event]}?

Sen13:07:47

I can't get routing working, namely the ability to make figwheel dev server to serve routes from my re-frame app. I found this repo https://github.com/quangv/re-frame-html5-routing checked it out and it works as expected, you go to any route and it runs index.html which starts the SPA, however, it uses bidi & pushy, I use secretary & accountant, will it make difference/work if I switch to bidi & pushy? Or it is something else in my project.clj? I added :ring-handler and dev_server.clj as in the example project, do I have to add something else?

bhauman13:07:40

that's the magic, you have to force index.html for other requests

Sen13:07:32

yeah, I have that in my app. Also, I'm using it with Spacemacs, maybe Cider messes up something?

bhauman13:07:32

and what specificly happens when you load a different route?

Sen13:07:12

It returns with Figwheel Server: Resource not found

bhauman13:07:50

do you have an index.html file?

bhauman13:07:37

and you've configured the server to be your ring-handler

bhauman13:07:38

can you add another route like /test and see that it is working?

bhauman13:07:30

this doesn't work

Sen13:07:49

if you mean :ring-handler option, then yes, it is :ring-handler my-app.dev-server/handler

bhauman13:07:50

the static files are handled before the index

bhauman13:07:09

you will have to use a resource response

bhauman13:07:14

basically the handler in that example is forwarding a request for index.html

Sen13:07:19

wait, let me try one thing, I think I messed up the path to dev-server

bhauman13:07:19

and that doesn't work

bhauman13:07:34

I don't think it will work

bhauman13:07:26

(ring.util.response/resource-response "index.html" {:root "public"})

Sen13:07:53

I'm a bit lost here, should I use it in project.clj or in dev-server?

bhauman13:07:35

in your dev server you are forwarding a request for index.html

bhauman13:07:56

you actually want to *return* the index.html file

bhauman13:07:50

in fact you can ignore all the other stuff in that server and just return the index.html

bhauman13:07:14

as all static files have been resolved by the time your ring-handler gets invoked

Sen13:07:50

🎉parrotit works! @bhauman thank you for help! So basically I just misspelled the namespace, stupid mistake, but the good thing, that this same approach works with secratary/accountant if any newcomers like me wonder if there is any difference

Sen13:07:51

Now I wonder why I didn't get any error that namespace doesn't exist

lwhorton15:07:52

what might be the best way to capture a re_frame db state before / after an error occurs? i was thinking an interceptor that just always maintains a ref to the current db - 1, and on error serialize both before/after db states. this also sounds like something that might already exist?

chrishacker15:07:10

I have re-frame-10x working, but for the Event part. I've described trying to plug in the re-frame-debux to get the Event portion working. Is anyone using the Event tracing successfully?

chrishacker15:07:10

@lwhorton I have been using console log stmts inside event handlers to introspect. That said, re-frame-10x does let you inspect the app-db in the browser and can show you the diff between two "Epochs" ie periods of events.

Vincent Cantin18:07:04

Is anybody here using datascript with re-frame? Via which library (I am currently reading the documentation of re-posh)? Is it a good experience as a dev or does it create problems?

p-himik14:08:52

About a year ago I wanted to use it in my project, but it turned out that datascript was about 10 times slower than using multiple get-in. In the end, I used a heavily modified version of subgraph.

Vincent Cantin17:08:27

10 times is huge! Did you happen to find out why it was so slow?

p-himik17:08:25

Not that huge if you make a small number of queries. 🙂 In my case, there was a decent amount, so using datascript would result in tens to hundreds of lost milliseconds. You should check issues on their GitHub page - there were discussions about performance issues.

👍 4
zalky00:08:29

@vincent.cantin, ditto on the performance limitations with datascript, and also ended up building ontop of subgraph. The flexibility of having normalized data with pull semantics, but still having your db be an associative structure is huge.

👍 4
Vincent Cantin02:08:16

I did not know subgraph, will consider it. Thx!

lwhorton21:07:36

@vincent.cantin i hesitate to use it. as awesome as it would be to have auto-normalized data in a datalog-backed query engine… sometimes its just too much effort to go against the flow

lwhorton21:07:23

you’re now tracking a lib that has to follow re_frame, and who knows how quickly it scoops up new features. how does it work with all the extensions such as re-frame-10x, async-flow, undo, etc.? lots of things to figure out

lwhorton21:07:00

so to answer you question, i don’t know. but those are the reasons i just stayed away. in the end update-in vs ? e where ?a in ?e didn’t seem worth it