re-frame

https://github.com/Day8/re-frame/blob/master/docs/README.md https://github.com/Day8/re-frame/blob/master/docs/External-Resources.md
bastilla 2021-04-27T19:16:59.346100Z

Hi. I just noticed that reg-event-fx ignores db alterations send via {:db alt-db if (and only if) it dispatches to another event via :fx [[:dispatch [::dlg-events/set-dlg {:dlg dlg ...} . As soon as I comment out the :fx part of the return map, db is handled normally, means the returned alterated form gets applied. Somehow :fx [[:dispatch is designed to interrupt here. Intentionally? If so, why? Thanks + best regards!

p-himik 2021-04-27T19:20:23.346200Z

I cannot reproduce it with re-frame 1.2.0. Can you create and share a repo with a minimal reproducible example?

🙌 1
bastilla 2021-04-27T19:20:57.346500Z

Pls ignore my question. As it is so often the case, the problem was produced right before the monitor.

bastilla 2021-04-27T19:21:47.346700Z

@p-himik Sorry(!!!) for stirring things up. And Thanks for your quick repsonse!!!!!

p-himik 2021-04-27T19:22:03.346900Z

Ah, a good old case of PEBCAC. :) No problem.

bastilla 2021-04-27T19:22:10.347100Z

lol, right

2021-04-27T20:10:20.348900Z

Folks, I am well and truly stumped. I am adding re-frame-10x version 1.0.2 to my project, but when I compile it, the compile aborts with the error Invalid :refer, var day8.reagent.impl.component/patch-custom-wrapper does not exist in file resources/public/js/out/day8/re_frame_10x.cljs. When I look at the source on github, though, patch-custom-wrapper is plainly there. https://github.com/day8/re-frame-10x/blob/d8dcb17e217449aba2cf64b9f843b0e9f86cfcb6/src/day8/reagent/impl/component.cljs#L80

2021-04-27T20:12:53.351Z

To make it more stump-provoking, if I look at resources/public/js/out/day8/reagent/impl/component.cljs, I find a file that contains two commented-out definitions for original-create-class and create-class, instead of the last three definitions as they appear in the version we find in github.

2021-04-27T20:13:53.352100Z

so it is missing from the file, but where the heck is this crippled version coming from? I’ve checked the history for the file on github, and there are only 2 commits, neither of which contain the crippled version that I’m seeing

2021-04-28T11:15:03.367500Z

Awesome, thanks much! I know it’s weird to have 10x and re-frisk in the same project, but it’s a multi-dev project and we each have our personal preferences, so it’s nice to have them play nicely together.

👍 1
p-himik 2021-04-27T20:20:41.352200Z

I am very suspicious of the path resources/public/js/out/day8/reagent/impl/component.cljs. Where does it come from? Why is js/out on your classpath?

2021-04-27T20:23:17.352400Z

It’s not, I’m deducing it from the error message. I’m assuming that’s just a temporary build directory used to construct main.js?

p-himik 2021-04-27T20:26:37.352600Z

Well, it is on your classpath - otherwise the compiler would've complained about some other path. It might not be on the lein process classpath, but it is there for the build process.

2021-04-27T20:29:55.352800Z

True. Temp classpath maybe? It’s got a directory tree that matches the list of dependencies for my cljsbuild, and each file in the tree has foo.cljs, foo.cljs.cache.json, foo.js and foo.js.map (where foo.cljs was the original file in the dependency).

lilactown 2021-04-27T20:38:32.358900Z

@manutter51 does the resources/public/js/out/.../*.cljs file actually exist on disk?

lilactown 2021-04-27T20:38:42.359200Z

or is that just in your browser devtools?

p-himik 2021-04-27T20:39:36.359300Z

I can understand that directory being there. I don't understand it being on the classpath. What's your project.clj?

2021-04-27T20:49:08.359500Z

:cljsbuild {:builds
              {:app
               {:source-paths ["src/cljs" "src/cljc" "env/local/cljs"]
                :figwheel {:on-jsload "infusion.core/mount-components"}
                :compiler
                {:main "<http://infusion.app|infusion.app>"
                 :asset-path "/js/out"
                 :output-to "resources/public/js/main.js"
                 :output-dir "resources/public/js/out"
                 :source-map true
                 :optimizations :none
                 :infer-externs true
                 :pretty-print true
                 :closure-defines {"re_frame.trace.trace_enabled_QMARK_" true
                                   "day8.re_frame.tracing.trace_enabled_QMARK_" true}
                 :preloads [re-frisk.preload
                            day8.re-frame-10x.preload]
                 :external-config {:devtools/config
                                   {:features-to-install [:formatters :hints]}}}}}}

p-himik 2021-04-27T20:52:54.359700Z

Do you have any other mention of :source-paths in the whole file, not just under the :cljsbuild key?

2021-04-27T20:53:26.359900Z

Oh hey, I reposted a generic version of the question in #clojurescript and thheller gave me a super tip. He had me fire up a repl and do

user=&gt; (require '<http://clojure.java.io|clojure.java.io>)
nil
user=&gt; (<http://clojure.java.io/resource|clojure.java.io/resource> "day8/reagent/impl/component.cljs")
#object[java.net.URL 0x6d55862e "jar:file:/Users/marknutter/.m2/repository/re-frisk/re-frisk/1.5.0/re-frisk-1.5.0.jar!/day8/reagent/impl/component.cljs"]
user=&gt;

2021-04-27T20:53:56.360100Z

Apparently re-frisk is the culprit here.

p-himik 2021-04-27T20:54:52.360700Z

Oh, interesting. I still have no idea why the compiler would complain about resources and not the jar or the resource name.

2021-04-27T20:54:55.360900Z

Yeah, it’s there. Check out the threaded replies, I think I have a good lead now.

2021-04-27T20:56:09.361Z

Yeah, I might have a wonky cache somewhere or something.

2021-04-27T20:56:26.361200Z

Definitely a weird one tho.

p-himik 2021-04-27T20:56:54.361400Z

Also might be worth it asking the author of re-frisk why he bundles day8/reagent/impl/component.cljs in there.

caumond 2021-04-27T21:01:24.363500Z

Hi, I'm struggling with internationalization. I have based my website on a value in the db. I wanted to get the accept-language value to be able to set the db value. Could you help me a little bit on how I'm supposed to do that? or a better way?

2021-04-27T21:01:27.363600Z

And especially why he bundles a broken version of it.

p-himik 2021-04-27T21:02:57.363800Z

It might not be broken for his use cases. But re-using namespaces is not great.

caumond 2021-04-27T21:04:19.364Z

I'm using tumpura and have already understood the interest to add the wrap-ring-request, except I don't have understood how to get that in the re-frame/cljs world.

caumond 2021-04-27T21:04:26.364200Z

if it helps

p-himik 2021-04-27T21:05:10.364400Z

Accept-Language is a request header - it's meant for a client to tell a server what language to use when serving the content. So, just serve the HTML with that language stored somewhere. In a &lt;meta&gt; tag, for example.

p-himik 2021-04-27T21:06:09.364600Z

I'm using languages set via URLs. So if there's a request for /, I determine the language via the Accept-Language header, then redirect to e.g. /en/ - this way, people with different browser settings will still be able to share pages that use the same language.

p-himik 2021-04-27T21:06:46.364800Z

And I have an explicit way on my websites to switch the language in a somewhat persistent way, because Accept-Language is not always accurate or preferred.

caumond 2021-04-27T21:12:18.365Z

so 1) you don't use the db at all, if I understood correctly 2) my issue is there, when I would need to retrieve the Accept-language in your / page for instance, I did not understood how to do that, I don't have any request clearly stated in my re-frame app. And when I look for re-frame and request, I find some discussion about effects

p-himik 2021-04-27T21:14:44.365200Z

I use app-db, but the initial value comes from a &lt;meta&gt; tag. You look for Accept-Language on the server side. It doesn't matter what makes the request and how exactly it was made.

caumond 2021-04-27T21:17:21.365400Z

ouch, I was definitely far from that solution

superstructor 2021-04-27T23:48:08.365700Z

Good to hear that is a false alarm, that would be a horrific bug 😱

superstructor 2021-04-27T23:53:20.365900Z

Looks like re-frisk is re-using our reagent monkey patches from re-frame-10x to get internal tracing. It is fine to use the code (10x is MIT license after all), but they should be renaming it like re-frisk.inlined-deps.day8.... or similar, otherwise this is going to burn people like yourself @manutter51 who have run both in the same project which is a totally valid use case that is even supported by the official re-frame-template.

👍 1