Fork me on GitHub
#fulcro
<
2018-12-07
>
tony.kay05:12:34

Fulcro 2.6.18 is on Clojars , and the Developer’s Guide has been updated. This new release has: - All SVG tags are now in DOM ns - A replacement macro for defrouter called defsc-router. It generates the same thing as defrouter (which still exists and is supported), BUT it has defsc syntax for better IDE integration, and more importantly allows you to do things like define react lifecycle methods on the router itself. This means you can add things like “route change” hooks into the router on :componentDidUpdate and such.

🚀 8
❤️ 8
bananadance 4
💎 4
kszabo10:12:14

hey, is there a possibility of combining multiple independent loads into a single remote query when using Pathom resolvers on the server-side? In my :started-callback code I have a lot of:

(df/load app :a/resolver a-sc {:parallel true})
(df/load app :b/resolver b-sc {:parallel true})
...
These currently fire as separate HTTP requests, but in theory they could be joined onto a single query (in some cases this would also increase performance as there are some interdependcies between the resolvers). I have found this function and the remainder of the ns: https://github.com/wilkerlucio/pathom/blob/master/src/com/wsscode/pathom/fulcro/network.cljs#L219 But it seems to only work on the old FulcroNetwork interface and is meant for cljs-side resolvers. Am I missing something?

claudiu11:12:34

@thenonameguy When you issue loads, fulcro has a small delay and has some logic for batching them into a request. If you put :parallel true they will go to the network directly as separate requests.

kszabo11:12:50

oh, so I am shooting myself with that premature optimization. Thanks! I don’t know if it’s missing from the book or I just couldn’t find it, but it might be worth adding a line about this. It totally makes sense though that this is the behavior.

claudiu11:12:02

You're welcome 🙂 Seems to be mentioned here, but it's also mixed with the mutation & load order http://book.fulcrologic.com/#_server_interaction_order You can override this behavior with the parallel option of load.

👍 4
kszabo11:12:23

argh, I was searching for ‘batched’ and skimmed over this.

Björn Ebbinghaus14:12:05

Is it possible to give a workspace fulcro defcard a global state AND an initial state for the "root" component (i am quoting root here, because the root component is wrapped by default).

(ct.fulcro/fulcro-card
    {::f.portal/root ui/LoginForm
     ::f.portal/app {:initial-state {:dbas/connection dbas/connection}}
     ::f.portal/initial-state {:id 1 :nickname "bjebb" :password "secret"}}))

wilkerlucio14:12:09

what you mean by global state? and the default value for initial state will be used as a param to your root entity, but you can use a fn version on it, then you can return whatever you like

Björn Ebbinghaus10:12:55

With global I meant the root node. I just wanted to add a field to the wrapping root node. But I have to manually add the initial-state of the wrapped component. Example:

::f.portal/app           {:initial-state {:dbas/connection dbas/connection
                                               :ui/root (prim/get-initial-state ui/LoginForm {:id 1 :nickname "bjebb" :password "secred"})}}}))

wilkerlucio13:12:47

@U4VT24ZM3 what connection is? it is some stateful thing?

Björn Ebbinghaus13:12:18

yes, in there is data to work with an external API. but since it is only a singleton I don't want to attach it to my LoginForm Component

wilkerlucio13:12:19

you can use the :shared support for fulcro, its a bad pattern to add stateful things to the app db, some advanced features might require it to be serializable

wilkerlucio13:12:04

this is also easier to set in the workspaces, you can provide as a separated dimension