Fork me on GitHub
#fulcro
<
2021-01-02
>
Mr. Savy03:01:45

For my infinite scroll, I want to take one item out of my storage vector (or just read the next item) and add it to the vector of ui items I currently have displayed. would that be best accomplished by a merge! or transact!? I'm thinking I could have an id associated with each item, and then I would call a transact! where I would pass in the id (or (inc id)) to load the next one. Perhaps there's a simpler way though? Maybe load!? I see there's an targeting/append-to option which seems like it might fit my use case. There's also df/load!... It seems like there's a lot of different options, but from what I'm reading append-to is probably the option I'm looking for.

Mr. Savy03:01:26

man load has a lot of options lol

Björn Ebbinghaus11:01:35

You definitely want to load! somewhere. I think you don’t want to load an infinite number of things. load! with :append-to sounds reasonable. BUT You want to keep the thing that are actually rendered small. Either: Paginate (which I don’t think you want for infinite scroll 🙂) Or have a look at virtualized lists in react.

🙏 1
holyjak13:01:42

Transact is the most generic operation. Load leverages it. Merge only inserts data you already have. So indeed load! with the right target is best as Bjørn says

holyjak16:01:42

I see Tony has previously proposed something like

(load! this :user/posts PostComponent {:target (t/append-to [:user/table id :user/posts] :params  {:pathom/context {:user/username "bob" :page n} } ) 
why does this not work for you? Not sure what you mean by > out of my storage vector (or just read the next item) and add it to the vector of ui items What is a storage vector? Do you mean a vector you have on the backend? That would imply that you indeed need load! since you want to load data from the backend.

👍 1
Mr. Savy18:01:10

yeah I'm using vectors to store backend data so it's just a vector of component data. thank you both! I will look into these suggestions

alex-eberts17:01:00

Hi Everyone - If you come across any audio glitches (coughs, loud pops, etc.) in Tony’s Fulcro videos on YouTube, please post the name of the video, the video link and the timestamp where the glitch occurs to the slack channel and I’ll fix it. Thanks!

❤️ 4
👏 1
Gleb Posobin02:01:53

Maybe add this announcement in video description/comments?

Mr. Savy23:01:25

when I trigger a load!, does it also need a corresponding defresolver like transact! does?

Gleb Posobin02:01:00

transact! doesn't need defresolver — transact! happens on the front end, it might have a remote section, then a request is sent to the remote. When the server handles the request, if it uses pathom connect, it will use the resolvers that allow it to answer the query.

❤️ 1
Gleb Posobin02:01:10

https://book.fulcrologic.com/#_mutations_that_trigger_one_or_more_loads "The `df/load!` function simply runs a `transact!` on an internally-defined mutation with a special `:result-action`."

Gleb Posobin02:01:12

It doesn't have to be a separate resolver with a unique name only for that load!: pathom connect will figure out a path to get the outputs you want from the inputs you provide, possibly through several resolvers.

Gleb Posobin02:01:54

So one resolver can have :user/username as input, :address/location-id as output, and another can have :address/location-id as input and :address/zip-code as output, if you send a query [{[:user/username "savy"] [:address/zip-code]}], pathom connect will figure out that it needs to run those two resolvers to respond to this query.

Mr. Savy03:01:01

ok thank you! so it sounds like i'll need to make sure I have the appropriate resolver to handle the input and produce the right output