ldnclj

Find us on #clojure-uk
agile_geek 2015-08-24T06:29:08.000592Z

Haway from a train in NE

pupeno 2015-08-24T07:53:21.000593Z

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

mccraigmccraig 2015-08-24T09:01:59.000594Z

@pupeno: re-frame in general

pupeno 2015-08-24T09:03:05.000595Z

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.

pupeno 2015-08-24T09:03:27.000596Z

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

pupeno 2015-08-24T09:04:26.000597Z

mccraigmccraig: are you using it?

mccraigmccraig 2015-08-24T09:06:49.000598Z

@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

thomas 2015-08-24T09:22:46.000599Z

morning

minimal 2015-08-24T09:47:49.000600Z

raining

mccraigmccraig 2015-08-24T12:47:38.000601Z

@agile_geek: how was your week of clojure ?

agile_geek 2015-08-24T13:17:21.000602Z

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

pupeno 2015-08-24T13:33:46.000603Z

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/

mccraigmccraig 2015-08-24T17:11:19.000605Z

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

mccraigmccraig 2015-08-24T17:23:47.000608Z

@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

pupeno 2015-08-24T17:25:21.000609Z

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

pupeno 2015-08-24T17:25:51.000610Z

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

mccraigmccraig 2015-08-24T17:31:46.000611Z

@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

mccraigmccraig 2015-08-24T17:37:20.000612Z

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

pupeno 2015-08-24T17:49:11.000614Z

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

mccraigmccraig 2015-08-24T17:50:35.000615Z

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

pupeno 2015-08-24T17:51:02.000616Z

I needed the result of handler1 before dispatching handler2.

mccraigmccraig 2015-08-24T17:52:02.000617Z

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

pupeno 2015-08-24T17:52:44.000618Z

Yes.

pupeno 2015-08-24T17:53:39.000619Z

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

mccraigmccraig 2015-08-24T17:55:15.000620Z

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

mccraigmccraig 2015-08-24T17:57:18.000621Z

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

pupeno 2015-08-24T17:59:41.000622Z

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.

mccraigmccraig 2015-08-24T18:02:30.000623Z

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

pupeno 2015-08-24T18:03:41.000624Z

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.