Fork me on GitHub
#clojure-uk
<
2019-05-19
>
practicalli-johnny03:05:32

I quite enjoyed the broadcast. I hadn't prepared anything, yet felt comfortable using a loop/recur, recursive function, repeat/map-indexed, and iterate/take approaches to solve the challenge.

practicalli-johnny03:05:22

I think this is the first time I've used map-indexed, it's neat.

zyxmn10:05:00

I find map-indexed very useful when you need to generate dynamic react elements and you can use the index value of the lazy sequence for the key attribute of each react element

dominicm12:05:11

I don't find myself doing this very often. I'm undecided whether it's a good idea, or if it is just cheating the react system. I think it depends on how your data will change.

zyxmn13:05:29

Yea of course there might be other ways to setting keys . How do you do it ? Why do you think the map-indexed might not be a good idea ?

dominicm15:05:29

The normal way is using the id of the resource from the server.

dominicm15:05:04

Using map indexed can be bad because if you delete an item, it will cause a cascading rerender, but most of the DOM nodes can be reused

dominicm15:05:20

> We donโ€™t recommend using indexes for keys if the order of items may change. This can negatively impact performance and may cause issues with component state.

zyxmn15:05:50

Holy shit . Thanks !

zyxmn15:05:17

Luckily I've only used it in generating lists where members are not deleted or re-ordered but sooner or later I would have come across one and used this same technique which might potentially be dangerous ! Phew ! Thanks again ๐Ÿ˜

dominicm15:05:57

It's a common mistake.

dominicm15:05:30

I'm not sure why I'm always pessimistic about obvious solutions ๐Ÿ˜Š but it leads me to stuff like this.

alexlynham10:05:22

phew, finished my serverless-cljs workshop materials

alexlynham10:05:54

the funny thing about writing a workshop is you figure it's done when it's done, but if you have to run it more than once it usually needs mostly rewriting

alexlynham12:05:27

Does make me conclude that haskell is maybe a better fit

alexlynham12:05:49

Well, or at least

alexlynham12:05:57

That node is garbage because of callbacks

alexlynham13:05:06

So the conclusion is to use promises

alexlynham13:05:35

But promises are like rubbish monads as you can't deref them anyway (like you can with async forms on the JVM)

alexlynham13:05:22

So you end up always setting up an io situation to test the damn things anyway (at least lambdas aren't big, I suppose)

alexlynham13:05:07

But you do think my gosh there has to be a better way is a better way

jasonbell14:05:21

That node is garbage because of callbacks

๐Ÿ˜‚ 16
๐Ÿ‘ 4