Fork me on GitHub
#re-frame
<
2016-09-23
>
dragoncube00:09:28

@danielcompton in case these 3 calls happen inside the handler with go block, would it block all other events processing?

danielcompton01:09:27

don’t quite understand your question, but in any possible scenario: no, anything happening inside a go block will happen asynchronously and can’t block events from processing

danielcompton01:09:54

The only way to block events from being processed is by doing CPU heavy work which will block the thread

andre06:09:05

@stuartmitchell hi guys. sorry for the delay, @mikethompson mentioned that it would be good to show data for components wich are rendering now, so, I was working on this, and I had to integrate in the component lifecycle, so i decided this shouldn't be in the production code, so i implemented compiler option for the re-frisk, to not generate any code in the production, last thing i wanted to do was draggable and resizable window with the data, and here I'm stuck , reagent works strange with the two reagent/render calls in one project, i don't want to integrate re-frisk in the app, i want separate div for it

andre06:09:14

i will try to release it today

andre07:09:43

good news, found the reason of strange behavior

andre08:09:41

i think i'm ready

andre09:09:41

one more strange thing, if i'm using only :require-macros , it doesn't include my cljs files , so i have my macro in clj file, it calls my function in the same namespace in cljs file, and if i :require this macro, it WARNING: Use of undeclare var which in my cljs file. hm

kalouantonis09:09:48

I’m not sure if this is what you mean, but you have to use the fully qualified name to refer to functions in the cljs files from clj macros. For example my-project.utils is a cljs function

(defmacro <?
  [expr]
  `(my-project.utils/throw-error (cljs.core.async/<! ~expr)))

kalouantonis09:09:05

@andre: Also, what did you use to make that gif?

andre09:09:39

yes. i'm using fully qualified name

andre09:09:03

LICEcap on windows

andre10:09:03

so, i'm stuck with the macro, i've compiled jar for clojars, included it in my project. :require-macros my macros, and it doesn't work 😞 if i requere my lib by :requere it works, but i can't release this 😞

andre10:09:29

i need to fix macro

andre10:09:17

using

(:require [re-frisk.core :refer-macros [def-view]])
instead
(:require-macros  [re-frisk.core :refer [def-view]]))
works fine, hm

andre12:09:20

Please provide any feedback, i'm waiting in any time 🙂

nilrecurring12:09:19

@andre testing it soon! Looks super useful so far, thanks! :)

robewald15:09:44

What is better: To have nested components with bound subscriptions by a let, like (let [my-react (subscribe ...))) or using subscribe only on the toplevel or something else?

shaun-mahood16:09:32

@robewald: I prefer top level subscribes where I can, but it's really dependent on what you are trying to do and what makes sense for your application. I like to think about whether that component should be interchangeable, what parts of the app or app-db it should know about, if there are performancw concerns, etc. before deciding on which way to go. I often end up refactoring and changing my original decision though.

timgilbert18:09:08

Hey all, anyone know of a ready-made re-frame effect that will dispatch another event after a timeout? Looking into implementing little status updates that close themselves after 5 seconds or whatnot

timgilbert18:09:33

It doesn't seem hard to implement myself, was just wondering if it already existed somewhere

johanatan19:09:10

Hi, I have a situation where a leaf component inside an outer dynamic component (with :key specified) is definitely being re-rendered when its r/reaction input changes. It renders some hiccup corresponding to a button with the btn-text as its first argument. The txt is changing from one call to the next however the inner button is only being rendered with the original text.

johanatan19:09:39

The inner button is a Form-2 component (i.e., (defn a-comp [txt other stuff] (fn [] [blah blah])). That lambda is getting called and blah blah is rendered with the original text but the setup in a-comp does not run even though txt is different from one run to the next (as verified by js/console.log from the calling component).

johanatan19:09:25

I would imagine that = comparison for two different text strings would produce a false and thus the component should be re-rendered (incl. its outer setup).

shaun-mahood19:09:51

@johanatan: Can you post a minimal repro of what's happening? My first impression is that there's something wrong with the way you've declared one of the components, since that's pretty standard functionality, but if you can get some code for me to work with I'm happy to go into more depth with it.

shaun-mahood19:09:02

The other possibility that seems likely to me is that there's some issue with how you are calling the inner component.

johanatan19:09:02

Sure, this feels very similar to the previous issues I hit around this functionality. I suppose it's time to bite the bullet and make a minimal repro.

shaun-mahood19:09:04

I find every time I have to go that far in troubleshooting it exposes the problem for me. I never want to do it, though. 🙂

johanatan19:09:01

Yes, there have been many similar issues for me over the last few weeks that I've been able to resolve without going that far. This one has withstood a couple of hours of the typical onslaught of debugging techniques though so either a) there really is a framework issue here or b) this one is trickier than usual

johanatan19:09:18

or c) my brain is behaving like it's 11 pm instead of 11 am (totally possible) 🙂

johanatan20:09:57

@shaun-mahood I have a minimal repro.

johanatan21:09:42

Although one can see "left" printed to the console, the bkg color of the label does not change from white to transparent. See: https://gist.github.com/johanatan/b67236e3440fdcc0e9ffc78aaf1bdb0d#file-minimal_repro-cljs-L36

johanatan21:09:04

[This isn't the exact failure that I'm seeing in practice: but it is really close (and certainly within the same class of failures)]

johanatan21:09:35

I can make the repro a bit more realistic if this turns out to be a red herring.

shaun-mahood21:09:39

@johanatan: great, I'll take a look and see if I can find anything useful

johanatan21:09:06

rgb should have been rgba

shaun-mahood21:09:10

@johanatan: It looks to me like there's an issue with how you are setting the background-color - if I replace :style {:background-color (if @hovered? "#ffffff" "rgb(0,0,0,0)")} with :style {:background-color (my-color @hovered?)} where my-color is defined with

(defn my-color [hovered?]
  (if hovered?
    "#ffffff"
    "#000000"))
it seems to all work

johanatan21:09:38

ok, i'll keep adding some complexity to make it more like the original

johanatan21:09:30

Actually with that fix the issue still repros

johanatan21:09:44

Notice that the label text doesn't change when you click on it

johanatan21:09:04

But if you peek in app-db, the selected set contains the clicked on items

shaun-mahood21:09:48

If you can set it up using the lein new re-frame +re-com template it will make it easier for me to test - I had to do some tweaking to your code to get it to run so I might have changed something that is giving you a problem.

johanatan21:09:48

i.e., the text should toggle between ALL CAPS and lower-case

johanatan21:09:08

How about I just push the entire repo?

shaun-mahood21:09:14

That would work too 🙂

shaun-mahood22:09:31

@johanatan: If you change your inner function to

(defn inner [label on-click]
  (let [hovered? (reagent/atom false)]
    (fn [label on-click]
      [re-com/label :label label
       :style {:background-color (if @hovered? "#ffffff" "rgba(0,0,0,0)")}
       :attr {:on-mouse-over #(reset! hovered? true)
              :on-mouse-leave #(do (js/console.log "left") (reset! hovered? false))
              :on-click on-click}])))
then I think everything will work - when I fix it, then the on-click handler fires and the text changes to all caps. Explanation for why is at https://github.com/Day8/re-frame/wiki/Creating%20Reagent%20Components#form-2--a-function-returning-a-function

johanatan22:09:26

Ahh! That has probably been my problem with Form-2 components all along!

johanatan22:09:41

That makes sense. I remember reading that but for some reason it didn't sink in lol

shaun-mahood22:09:10

Yeah it's pretty important. It was a source of a lot of errors for me when I started with re-frame, and is still the first thing I check 🙂

johanatan22:09:09

Too bad my initial message: "The inner button is a Form-2 component (i.e., (defn a-comp [txt other stuff] (fn [] [blah blah]))" wasn't enough to give it away

shaun-mahood22:09:17

I thought that might be the case, but I don't like jumping to too many conclusions - way nicer to be able to work through the real problem instead of a bunch of wild guesses. Semi-related, if you haven't seen this talk it's one that I recommend any time I get a chance - https://www.youtube.com/watch?v=FihU5JxmnBg

johanatan22:09:58

I don't really consider that a wild guess as a) it is a commonly stumbled over detail b) my actual initial code example posted clearly exhibited the problem c) it is still scientific to say "here are a few common things to check" (and linking to that article)

johanatan22:09:15

It is more like an extremely informed and educated guess-- almost to the level of a deduction really given the code sample posted.

johanatan22:09:31

But, anyway, thanks for the help!

shaun-mahood22:09:07

Oh, I had other wild guesses waiting in the wings for you if that one didn't work 🙂

johanatan22:09:40

Also, if you had made an attempt to understand what was meant by this: "That lambda is getting called and blah blah is rendered with the original text but the setup in a-comp does not run even though txt is different from one run to the next (as verified by js/console.log from the calling component)", you'd have seen that my expectations were not correct.

johanatan22:09:02

I expected the "setup in a-comp to run" which was clearly not how this works.

johanatan22:09:10

Rather the new arguments are passed into the inner lambda

johanatan22:09:15

And thus one needs to capture them there.

shaun-mahood23:09:55

Yes, I had some ideas on how to progress and I also had some ideas about where your expectations might have been incorrect. I've also seen your previous questions and I decided based on those that I would rather try and help in a more substantial fashion so you could better understand how things are meant to work in the context of your code, as I find that it is a better way to communicate than simply referring you to the documentation. Hopefully you have a better understanding of things now.

johanatan23:09:28

Honestly an answer like "your inner lambda needs to recapture the component props for Form-2 components" would have been perfectly understandable and helpful to me.

johanatan23:09:39

[And this was in fact the only thing wrong with any of my code that I've sought help on here for-- the only difference is that the last time(s) I didn't go through with the min repro song & dance]

johanatan23:09:08

Anyway, I appreciate your style-- I just prefer more direct answers apparently.