Fork me on GitHub
#reagent
<
2016-04-18
>
Tim05:04:46

1 thing I don’t quire get in reagent: (map (fn [i] [:p {:style {:font-size "16px"}} i]) li) and

(for [i li]
      [:p {:style {:font-size "16px"}} i])
seem to work and do the same thing

Tim05:04:01

but for some reason this doesn’t work

(doseq [i li]
      [:p {:style {:font-size "16px"}} i])

Tim05:04:49

I understand that for returns a lazy sequence, but why wouldn’t doseq work?

gadfly36105:04:10

@tmtwd doseq returns nil

Tim05:04:38

its just for side effects

danielcompton11:04:55

@tmtwd: if you want to force evaluation, you can use doall

drapanjanas15:04:19

Has somebody implemented an ‘infinite scroll’ component in reagent/re-frame webapp? Or maybe used some existing OS one? I am doing a chat view and need to show older messages when you scroll up. There are some components for react available, but I’m not sure how to setup any of those in my project. Maybe it worth building from scratch?

martinklepsch16:04:39

the above is "auto-scroll", not infinite/lazy-load scroll

drapanjanas16:04:56

@martinklepsch: thanks anyway, I guess I can add some lazy loading

martinklepsch16:04:33

This conversation made me wonder, how to write a auto-scroll thing and an infinite-scroll thing in a way they can be nicely composed?

mccraigmccraig16:04:44

@drapanjanas: i've got one... you are welcome to have a look if that would be useful, though it's kinda tied to some of my app concepts

drapanjanas16:04:44

@mccraigmccraig: yeah I would like to, well I am thinking what to do, so you chose to build one your one right? I need only lazy loading for now, as simple as possible, and don’t want to depend of half of internet.

drapanjanas16:04:23

@mccraigmccraig: thanks a lot! It will help me to decide

nberger16:04:22

@drapanjanas: here's the reagent infinite scroll component that we have in Roomstorm: https://gist.github.com/nberger/b5e316a43ffc3b7d5e084b228bd83899. We use it with re-frame, but of course you can use it with just reagent, you just need to give it a map with :position :can-show-more? :load-fn keys

martinklepsch16:04:14

@nberger: is it intentional that this component doesn't render anything? or did you omit that?

nberger16:04:08

Well, yeah, it doesn't take care of rendering our "infinite list"

martinklepsch16:04:13

oh, this is global and so you don't need it. got it

nberger16:04:56

so we have a [ul ...] with our items, and below it this component... it works for us simple_smile

martinklepsch16:04:04

if you have only one thing which you want to infinitely scroll that makes sense

nberger16:04:53

and I now see that we are not using the position at all... so just can-show-more? and load-fn. If can-show-more? is true and it detects we are close to the bottom of the page, it triggers load-fn

drapanjanas17:04:23

@nberger: cool, I use re-frame in my webapp, thanks a lot!

nberger17:04:57

Np! let me know if you find anything to improve it simple_smile

jfntn23:04:24

Hi folks, I just started integrating re-frame in an existing app today, and very much liking it so far!