Fork me on GitHub
#fulcro
<
2018-06-27
>
dvingo02:06:43

@tony.kay re the bug report I submitted - I wasn't sure what format is best to submit. Let me know if you want me to update it in anyway. whatever's easiest for you!

Chris Swanson04:06:54

awesome, just tried 2.0.0-beta2, works perfect. I think it's more intuitive this way - certainly it feels the natural approach to me.

tony.kay06:06:11

@danvingo Thanks…just have not had time to look at it.

dvingo10:06:51

Okay cool, no problem! Just wanted to make sure you weren't waiting on me for anything. I will see if I can dig a bit further into as well.

tony.kay17:06:15

Love it if you want to dig in…I sent you instructions in the issue

claudiu06:06:00

@chrisjswanson Also tried SUI but giving up on it. Most of the stuff I can easily do and looking at the bundle size it's just crazy... almost doubled (not to happy about the 100kb of lodash), importing components one by one does not work that well (to get dead code elimination), button+dropdown pulls in most of the code anyway. Now going for http://bulma.io + the bulma extensions for css stuff and just writing my own logic.

tony.kay06:06:02

Yeah @claudiu I am using semantic CSS, but not their JS…most of the active components are pretty silly simple in terms of logic

chrisblom07:06:56

How is the react “key” attribute derived for a component? Is it possible to override it?

claudiu08:06:23

think this is what you're looking for (def ui-person (prim/factory Person {:keyfn :person/name})) " http://book.fulcrologic.com/#_factories

chrisblom08:06:06

@claudiu thanks, that was it

currentoor17:06:22

@claudiu lol yeah you're right, i think i'll take @tony.kay's approach and only use the CSS from SUI

wilkerlucio19:06:51

people, did some of you implemented pagination with fulcro? I'm doing some now and I wonder how you are doing to do the pagination loads (after initial), in my approach I'm trying to wrap the pagination so it can be generalized, the query looks like this:

{:customer/paginated-purchases
 [:page/next-cursor
  {:page/items (fp/get-query Purchase)}]}

wilkerlucio19:06:59

there 2 issues I'm trying to figure out:

wilkerlucio19:06:22

1. how to trigger a load sending a param to that attribute (not to the ident join, so we can send the cursor to determine the next page scope)

wilkerlucio19:06:40

2. how to add the items to the result collection, if I just load it will override the items, which is not desired

wilkerlucio19:06:10

if any of you have some experience/opinions, I'll be glad to hear

wilkerlucio20:06:41

ok, I think I got something that works

wilkerlucio20:06:19

1. to trigger the load I had to fallback to directly calling fulcro/load mutation, so I can set the parameter right when building the query

wilkerlucio20:06:47

2. I setup a post-mutation that knows the previous items, so on the post-mutation I merge then back

wilkerlucio20:06:55

this is code in case anybody is interested:

wilkerlucio20:06:11

(fm/defmutation merge-page-items [{:keys [abrams.page/items page-key]}]
  (action [env]
    (db.h/swap-entity! env update-in [page-key :page/items] #(into items %))))

(defn load-next-page [this {:keys [page-key load-config]}]
  (let [ref           (fp/get-ident this)
        state         (-> (fp/get-reconciler this) fp/app-state)
        cursor        (-> (fp/props this) page-key :page/next-cursor)
        current-items (get-in @state (conj ref page-key :page/items))
        load          (merge {:query                [{ref [(-> (fp/get-query this)
                                                               (fp/focus-query [page-key])
                                                               first
                                                               (list {:page/cursor cursor}))]}]
                              :post-mutation        `merge-page-items
                              :post-mutation-params {:page/items current-items
                                                     :page-key          page-key}}
                             load-config)]
    (swap! state update-in ref assoc-in [page-key :page/items-swap] current-items)
    (fp/transact! this [(list 'fulcro/load load)])))

👍 4
claudiu10:06:27

is the last line using df/load inside a mutation ?

wilkerlucio12:06:46

ah, that is using the load directly, the df/load calls the fulcro/load internally

tony.kay22:06:40

I also have a pagination example in the book. Paginating Large Lists, I think it is called…does sliding window caching so “nearby” pages are kept, and others are “released”

wilkerlucio16:06:05

I was checking it now, but seems its client only, my concerns are more about client/server things on it

tony.kay16:06:37

it’s full stack

tony.kay16:06:21

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; SERVER:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(server/defquery-root :paginate/items
  "A simple implementation that can generate any number of items whose ids just match their index"
  (value [env {:keys [start end]}]
    (when (> 1000 (- end start))
      (vec (for [id (range start end)]
             {:item/id id})))))

tony.kay16:06:32

it’s simulating the server in the browser, but it is full-stack logic

wilkerlucio16:06:07

ah, gotcha, I stopped reading in the first section facepalm