Fork me on GitHub
#re-frame
<
2021-04-27
>
bastilla19:04:59

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-himik19:04:23

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

🙌 3
bastilla19:04:57

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

bastilla19:04:47

@U2FRKM4TW Sorry(!!!) for stirring things up. And Thanks for your quick repsonse!!!!!

p-himik19:04:03

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

superstructor23:04:08

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

manutter5120:04:20

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

manutter5120:04:53

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.

manutter5120:04:53

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

p-himik20:04:41

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?

manutter5120:04:17

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-himik20:04:37

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.

manutter5120:04:55

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).

p-himik20:04:36

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

manutter5120:04:08

:cljsbuild {:builds
              {:app
               {:source-paths ["src/cljs" "src/cljc" "env/local/cljs"]
                :figwheel {:on-jsload "infusion.core/mount-components"}
                :compiler
                {:main ""
                 :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-himik20:04:54

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

manutter5120:04:26

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=> (require ')
nil
user=> ( "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=>

manutter5120:04:56

Apparently re-frisk is the culprit here.

p-himik20:04:52

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

manutter5120:04:09

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

manutter5120:04:26

Definitely a weird one tho.

p-himik20:04:54

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

manutter5121:04:27

And especially why he bundles a broken version of it.

p-himik21:04:57

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

superstructor23:04:20

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.

👍 3
andre05:04:00

sorry about that, will fix it soon

andre06:04:46

@manutter51 fixed [re-frisk "1.5.1"]

manutter5111:04:03

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.

👍 2
lilactown20:04:32

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

lilactown20:04:42

or is that just in your browser devtools?

manutter5120:04:55

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

caumond21:04:24

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?

caumond21:04:19

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.

caumond21:04:26

if it helps

p-himik21:04:10

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 <meta> tag, for example.

p-himik21:04:09

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-himik21:04:46

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.

caumond21:04:18

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-himik21:04:44

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

caumond21:04:21

ouch, I was definitely far from that solution