Fork me on GitHub
#fulcro
<
2018-06-28
>
claudiu07:06:05

@wilkerlucio Not sure this is the best approach, was in a rush to finish a project (fulcro 1.21 days). I have a prop in the container component :ui/append-loaded. The post mutation looks it up and decides how to add the data. Something like:

claudiu07:06:18

(defui ^:once SearchQuery
  static om/IQuery
  (query [this] [:has-more?
                 {:admins (om/get-query AdminAdminsListing)}]))
                                  
(defn load-data-fn [this params]
    (f-df/load this :server/admins SearchQuery {:params        params
                                                :post-mutation `m/finish-load!
                                                 :refresh       [:search-results]}))
                                                 
(defmutation finish-load!
  [params]
  (action [{:keys [state ref] :as env}]
    (let [s      @state          
          append-loaded? (get-in s (conj ref :ui/append-loaded))]))

wilkerlucio09:06:13

@claudiu thanks for sharing, but this approach of having the pagination outside I think is a problem, because if you have multiple paginated collections then it falls short

claudiu10:06:47

@wilkerlucio what do you mean by multiple paginated collections ? 🙂

wilkerlucio10:06:09

I mean, the way you said the :has-more? is at the same level of your collection :admins, what if also have :customers what's a paginated

wilkerlucio10:06:30

also, having it at the upper level compromises the ability to generalize the solution for the pagination UI

wilkerlucio10:06:52

I like the nested structure because it allows for more meta-information like total pages, current page, and whatever else it needs

claudiu10:06:18

ahhh 🙂 yep. Did not reach that case. But :has-more? it's the post-mutations job to put it in the appropriate place (using-ref). But if I had multiple collections, then each would have there "wrapper-component" & list-view component, the wrapper should have ident and hold the has-more, total-pages, current-page, collection items list.

claudiu10:06:37

or at least that's my current approach. Need to think about this a bit more, and see what edge-cases can pop-up 😄

claudiu10:06:12

@wilkerlucio trying now to get graphql with lacinia on the server, then create a graphql networking remote. In theory that is the place where I should use pathom to convert the edn to graphql, and the response back to edn ? Have you tried this on any project ?

wilkerlucio10:06:43

@claudiu yes, I might have some example around, I'm in a meeting now, I can look it up later

wilkerlucio11:06:25

@claudiu I was checking here, but I think the old examples will not work due to recent changes, I can help you out to make this setup because there is no ready to use example at this point

claudiu12:06:43

@wilkerlucio that would be great, thank you. 🙂 Still setting up some things on the backend, will try to setup graphql+pathom and give you a shout when I get stuck.

claudiu14:06:54

Is there a big difference in performance between dynamic routing (set-query) and the union routing ?

tony.kay14:06:40

@claudiu nearly none. Dynamic routing relies on dynamic queries, which are AFAICT are much less used, and therefore less “tested”

tony.kay14:06:52

though I have quite a few unit tests around that whole area

tony.kay14:06:15

Dynamic queries have a touch more overhead than a union

tony.kay14:06:24

but on the order of microseconds probably

claudiu14:06:31

Oh oky cool. :) Using dynamic router now, so far so good.

tony.kay14:06:11

good to hear

claudiu14:06:34

Is there any reason to use dynamicrouter if I'm handling the modules loading myself vs just implementing it with set-query! ?

tony.kay14:06:51

dynamic routers also require the reconciler on route change to process code loading…with union routers you can just use (and compose) update-routing-links in any mutation

tony.kay15:06:23

as with any code…you can implement any of this stuff yourself.

tony.kay15:06:02

you, of course, need dynamic queries in order for code splitting to be possible

Pontus19:06:16

is there any way to use react fragments in fulcro? (https://reactjs.org/docs/fragments.html)

wilkerlucio19:06:38

@pontus.colliander had you tried to just use directly? I think there is nothing preventing it from been used

Pontus19:06:29

Do you know what the syntax would look like to use it directly? I tried

(react/createElement react/Fragment (dom/span "span1") (dom/span "span2"))
and variants of that but no luck

wilkerlucio19:06:56

@pontus.colliander I guess: (dom/create-element js/React.Fragment #js {:prop "value"} (dom/div "Child"))

Pontus19:06:30

Cool! Thanks a lot

wilkerlucio19:06:07

cool, glad to hear 🙂

wilkerlucio19:06:27

I think we should add this to the dom namespace, or some other place, since it's a react core piece

👍 4
tony.kay19:06:19

Yes, but we should also probably make React 16 the min version of react as well. While we’re at it we also need to support the new lifecycle methods

tony.kay19:06:05

all of these are steps we should be taking in prep for the async rendering coming in 17 as well…there’s an issue already open

wilkerlucio20:06:02

I'm still on React 15 here, but I'm planning to migrate soon

wilkerlucio20:06:22

but I'm worried it might not be an easy migration, given I have tons of dependent libraries that came before

wilkerlucio20:06:27

so, I have to try and see

tony.kay20:06:28

I’m using 16 in a fairly large project…working fine for me

tony.kay20:06:52

been out for a while, so only really stale libs are a problem