Fork me on GitHub
#ldnclj
<
2015-08-24
>
agile_geek06:08:08

Haway from a train in NE

pupeno07:08:21

mccraigmccraig: do you mean re-frame in general or the server side rendering?

mccraigmccraig09:08:59

@pupeno: re-frame in general

pupeno09:08:05

mccraigmccraig: I haven’t used it a lot. I had a bit of trouble when I wanted to run handlers in sequence, but eventually I figured it out. I do wonder whether other issues like that will pop up as the project becomes more complex.

pupeno09:08:27

mccraigmccraig: I would likely stick to re-frame, as without it, I would probably build something like it anyway.

pupeno09:08:26

mccraigmccraig: are you using it?

mccraigmccraig09:08:49

@pupeno: i think so, i've been distracted by back-end stuff for a while, but i'm just about to do a front-end push, and re-frame seems like a sound idea

mccraigmccraig12:08:38

@agile_geek: how was your week of clojure ?

agile_geek13:08:21

@mccraigmccraig good. Although a little frustrating at how long it took me to make progress.

pupeno13:08:46

I just released a new version of to-jdbc-uri, now with MySQL support: https://carouselapps.com/2015/08/24/jdbc-uri-0-3-0-released/

mccraigmccraig17:08:19

@pupeno: what did you mean by "run handlers in sequence" ?

mccraigmccraig17:08:47

@pupeno: did you check out the core.async channel monad from cats ? used with mlet (do notation) it makes for straightforward step-wise async computations, and with alet (applicative do notation) you can do efficient concurrent & dependent async computations

pupeno17:08:21

I know about core.async channel’s, but not under the name monad (and not sure what cats is there).

pupeno17:08:51

I don’t see how core.async can help run one handler after the other though.

mccraigmccraig17:08:46

@pupeno: you want to run a sequence of async operations, possibly dispatching after some intermediate steps, and then dispatch the combined results... using the channel monad gives you a really nice way of doing stepwise async operations (which return core.async channels), which looks just like a (let [...]) but is all async

mccraigmccraig17:08:20

oh, and cats is a clj/cljs monad impl : https://github.com/funcool/cats

pupeno17:08:11

mccraigmccraig: but these are handlers, async can’t magically make handlers syncronous.

mccraigmccraig17:08:35

sure, but you have control of when you dispatch to the handlers... you can have an async op which dispatches to the handlers in a given order - the handlers themselves don't need to know

pupeno17:08:02

I needed the result of handler1 before dispatching handler2.

mccraigmccraig17:08:02

isn't it the results of api-call-1 you need to make api-call-2 ?

pupeno17:08:39

Well, yes, but also the post-processeing done by the handler call-back.

mccraigmccraig17:08:15

would something like this do the trick then : https://www.refheap.com/108679

mccraigmccraig17:08:18

that gets sequenced such that api-call-2 will be made when the result r1 is available, and when the result of api-call-2 is available the final dispatch will be done

pupeno17:08:41

Not sure about the semantics of m here, but I don’t think it’ll work. dispatch will return immediately, without running the handler, so by the time api-call-2 happens, the handler hasn’t run yet. For api-call-2 I need the result of handler-1 (as in a modification to db), not of api-call-1.

mccraigmccraig18:08:30

ah, gotcha... so you would want something like a core.async version of subscription, which would return a value from a channel when some db-related condition was fulfilled... i don't know enough about the re-frame/reagent internals yet to suggest what that would look like

pupeno18:08:41

Well, the solution I found is ok. Not brilliant. I think where you are going would require re-writing re-frame in terms of core.async or something like that, which might not be a bad idea.