Fork me on GitHub
#fulcro
<
2019-12-19
>
daniel.spaniel11:12:07

doing df/load with query params worked out very will with your

query-params-to-env-plugin
@tony.kay so thanks for that one .. was very simple to do query params with that plugin

daniel.spaniel11:12:03

on a side note // is there a script to upgrade to fulcro3 ? i thought you said while ago there was, but not sure if I remembered correctly

tony.kay14:12:00

I started to write one, but it turned out to be a bit of work to automate well, and no one wanted to fund it…so…do it yourself via the doc: https://github.com/fulcrologic/fulcro/blob/develop/PORTING-FROM-2.x.adoc It really isn’t that hard. Mostly it’s adding this to react lifecycle methods and renaming things, which Replace In Path in IntelliJ does a nice job of.

fjolne16:12:50

hi, there! i’m wondering what is the suggested approach to do component load on route change in case of dr/route-immediate. docs say that :will-enter should be free of side-effects, so i see only 2 ways: to couple load with dr/change-route and to use :componentDidMount. both seem to be kinda problematic (the first is coupling, the second is semantically incorrect). there’s yet another way: to call dr/target-ready immediately (not as a post-mutation), but i recall you mentioned you’re not using dr/route-deferred that much, so i expect there’s a saner way

currentoor17:12:44

what’s wrong with route-deferred?

currentoor17:12:09

(defsc ReceiptTab [this {:keys [order]}]
  {:initial-state {}
   :ident         (fn [] [:COMPONENT/by-id ::receipt])
   :query         [{:order (prim/get-query receipt/OrderSummaryModal)}]
   :route-segment ["receipt" :order-id]
   :will-enter    (fn [app {:keys [order-id]}]
                    (let [id (uuid order-id)]
                      (dr/route-deferred [:COMPONENT/by-id ::receipt]
                        #(df/load app [:order/id id] receipt/OrderSummaryModal
                           {:post-mutation        `dr/target-ready
                            :marker               false
                            :target               [:COMPONENT/by-id ::receipt :order]
                            :post-mutation-params {:target [:COMPONENT/by-id ::receipt]}}))))}
  (receipt/ui-order-summary-modal order
    {:on-close #(uism/trigger! this ::om/orders-machine :event/to-detail)}))

currentoor17:12:15

i use it like that all the time

tony.kay17:12:37

What he said ^^^^. Side-effect free means the side effects need to go inside the route-deferred return value, so that will-enter can be called any number of times while routers are trying to resolve the correct route based on the path. I’m starting to prefer using a UISM any time there is any complexity, since there is usually more than just “load this on route” in the overall application…so you solve that bit there and then still run into some other thing you want to do/keep track of, and it ends up scattered in the UI…UISM let’s you gather it into a coherent picture

currentoor18:12:58

yeah another big advantage of the UISM is it’s easy to trigger loads, show a loader, then route when you actually have the data

currentoor18:12:19

use route-deferred makes it a little difficult to show a loader why the data is being fetched

currentoor18:12:34

unless im missing something

fjolne19:12:56

@currentoor exactly last point: i want to navigate to the route asap and show the loader there. also, in case of deferred routing it’s more difficult to make it in sync with HTML5 routing (have to set the token after the load)

mdhaney19:12:03

Glad to see I’m not the only one who has stopped using route-deferred in favor of a state machine. And for exactly the reasons mentioned - to show a loader (especially important on mobile) and to consolidate the logic in one place.

fjolne19:12:11

i’m kinda going back and forth with UISM trying to not introduce it in simple enough cases — FSMs have a cognitive load per se (or I’ve just shoot my feet too often with redux sagas)

fjolne19:12:13

@tony.kay so, it’s fine to transact dr/target-ready in parallel with df/load! inside dr/route-deferred arg fn?

fjolne19:12:33

no side-effects, at least

fjolne19:12:22

*as opposed to chaining tartget-ready as a post-mutation of load

tony.kay19:12:16

@fjolne.yngling yeah, that should not hurt anything

fjolne19:12:45

cool, thanks!