A Cells port of David's core.async webinar on avoiding Callback Hell

151 views
Skip to first unread message

hiskennyness

unread,
Jul 25, 2016, 2:46:07 PM7/25/16
to Clojure
As I watched David Nolen's compelling core.async web client webinar (http://go.cognitect.com/core_async_webinar_recording) I started to wonder if CSP was not another metaphor for Cells (the spreadsheet being another, and in FRP we have a time series or stream or something).

So I went ahead and redid the ten examples as closely as possible* using Cells.


The README may soon be expanded, but if I do it will just be a reformatting of the heavily annotated:


Along the way I concluded Cells is not CSP, unless by communicating we mean "broadcasting whether or not anyone is listening and to whoever is listening". But my annotations turned out to be decent documentation of Cells, including a new "gotcha" I encountered recently for the first time in twenty years of Cells (suggesting the artificial code examples are unuse cases, which we already knew). That brings me to the long-awaited asterisK.

* In examples 4&5 David motivates then fixes a case where a coder is misled by the simplicity of a "go" form and tries to put to a channel and then take that value in the next statement, ending up blocked forever. That cannot happen with Cells, so I coded up the Cells "gotcha":

   (if (or cell-a cell-b) ....)

Cell depedencies are decided after each invocation of a cell formula and include only those other cells actually read, so once cell-a is true there will be no dependency on cell-b, so only cell-a is "heard".

Final note: I have seen "callback hell" a couple of places now. I guess Cells is hiding that from me. I do recall using qooxdoo's "message" hack to great effect in the brief time I did clients without Cells.

-kt




Reply all
Reply to author
Forward
0 new messages