Fork me on GitHub
#fulcro
<
2020-04-24
>
JAtkins00:04:41

How are long running mutations typically handled in Fulcro? I have an app where most of the page is graphs. I'd like to have them update as often as possible, but the page will lock up for ~0.3 seconds while re-calculating the data and re-rendering. Is it possible to pause a mutation halfway through (with still consistent data) and continue updating on the next ui keyframe?

currentoor00:04:02

i think you’re going to have to break your mutation up into smaller mutations

currentoor00:04:34

fulcro does use requestAnimationQueue to do it’s processing, but mutation actions are atomic

JAtkins00:04:47

Right. I can do that, but can I chain them so that the first ends and it queues the next partial?

currentoor00:04:27

correct, you can transact additional steps inside mutations in fulcro 3

currentoor00:04:52

now if that is still too cumbersome, you can add some setTimeout delays

JAtkins00:04:51

Oh, cool. I didn't know if it was possible or not. Not to cumbersome, I just couldn't figure out how to perform a transaction inside a mutation. Time to hunt it down.

currentoor00:04:35

mutation env gets app

currentoor00:04:48

you can call (comp/transact app [(…)]

currentoor00:04:53

in a mutation action

JAtkins00:04:16

Oh, duh. Thank you! I was trying to find out why it is always (comp/transact this ...). I'm assuming that fulcro just follows the this component up to get the app to do the transaction on?

JAtkins00:04:52

Perfect. That's a much simpler solution than I expected.

currentoor00:04:12

happy to help

levitanong05:04:07

Oh look, JS is finally catching up: https://loonajs.com/

😆 4
fjolne10:04:40

the last commit by a human being appears to be from 2018 though

levitanong05:04:42

Oh my word that is a cumbersome API

punit-naik14:04:55

Guys, I am new to Fulcro and I had a small question: I have a UI component which is "subscribed" on a particular key in the browser DB. When I run the mutation, I can see that the state of my browser DB changes to reflect the exact change I did in the mutation, but my component does not re-render. What could be the issue?

folcon15:04:34

This could be an ident thing? I’ve hit that issue before =)… Try doing this as a quick test:

[com.fulcrologic.fulcro.rendering.keyframe-render2 :refer [render!]]

(defonce SPA (app/fulcro-app
               {:remotes {...}
                :optimized-render! render!})) ;; Pass it in here to change your renderer.
If that fixes it, then you can either leave it like that for now (I’ve done this), or work out how to update ident’s correctly =)…

mdhaney16:04:38

Has there been a discussion about changing the default renderer? I imagine the reason it hasn’t been done is for backward compatibility. But for all new users , we should make it very clear that the first thing they should do is change to keyframe-render2 as @folcon said above. I know it’s in the docs, but in chapter 19 or something like that. Maybe a big old message at the top of the dev guide, template, etc. would help? I only bring it up because this is the second new user in 12 hours (and many, many more in the past) with problems related to using the default ident-optimized renderer, which is a more complicated and usually unnecessary optimization.

JAtkins19:04:45

Maybe lengthen the blurb in the docs a bit. It wasn't too hard for me to find the relevent docs when I was running into the same issue. The primary issue there was that I was still hesitant to switch to keyframe-render2. I ended up needing some more info overlayed to change.

folcon16:04:58

It took me a fair while to work out this was a problem :)... I don't even know what the performance penalty is :)...

mdhaney16:04:55

IIRC, there are real trade offs between ident and original keyframe renderer, and which performs better would vary depending on your app. But keyframe2 in most cases outperforms them both, and is pretty much the best of both worlds.

mdhaney16:04:58

That’s what I recall from the discussion when Tony originally released keyframe2, but I might be remembering wrong, and I haven’t done any formal benchmarks or have numbers to back it up, so grain of salt time. But I do think saying keyframe2 should be the starting point and optimize with ident renderer later if needed is a pretty uncontroversial statement. We just need to get the message out better.

folcon16:04:36

I would think that updating the default template would help a lot, there’s an expectation of how do I get started? => I’ll just use the template

fjolne16:04:06

@mdhaney multiple roots renderer (based on keyframe2) is the default since Fulcro 3.2.2

mdhaney16:04:25

@fjolne.yngling ah, that’s great! Should help a lot going forward.

fjolne16:04:14

yeah, with the hooks support there appeared a new cool way to manage transient components with real state, but that required multiple roots renderer to work

folcon17:04:55

I didn’t quite understand that video, would you mind briefly expanding?

folcon18:04:41

Thanks, I'll take a look at it :)...

fjolne16:04:07

Tony shared it some weeks ago but you know slack history...