This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-12-07
Channels
- # adventofcode (38)
- # aleph (1)
- # bangalore-clj (3)
- # beginners (126)
- # boot (165)
- # boulder-clojurians (5)
- # cider (42)
- # cljsrn (11)
- # clojure (203)
- # clojure-greece (6)
- # clojure-hk (1)
- # clojure-italy (11)
- # clojure-new-zealand (1)
- # clojure-nl (1)
- # clojure-russia (112)
- # clojure-spec (86)
- # clojure-uk (176)
- # clojurescript (38)
- # code-reviews (2)
- # core-async (2)
- # cryogen (2)
- # cursive (16)
- # datascript (2)
- # datomic (80)
- # events (2)
- # garden (28)
- # hoplon (115)
- # jobs (1)
- # jobs-discuss (7)
- # klipse (50)
- # lein-figwheel (15)
- # liberator (17)
- # luminus (6)
- # off-topic (8)
- # om (31)
- # onyx (26)
- # parinfer (4)
- # planck (35)
- # protorepl (26)
- # quil (2)
- # re-frame (50)
- # reagent (21)
- # ring (5)
- # rum (2)
- # schema (1)
- # untangled (29)
- # vim (10)
- # yada (40)
@weavejester hi, I have readed a little bit the ring 1.6 async support and I have a question: why the async handlers has two callbacks, one for continue and the other for raise. There are some rationale for this?, I think that it can be simplified just to one callback called next
and capture error by the type. In fact, the handling of the value passed to the next
callback can be handled using protocols, so allowing to the user define its own behavior...
@niwinz I like having error handling and normal control flow separated. It makes the code clearer as handlers and middlewares don't have to dispatch first (all of them would have to do it).
@niwinz We have respond
and raise
for much the same reason that we distinguish between the return value and throw
. In theory we could return exceptions instead of throwing them, and then dispatch on the type of the return value. In practice, it’s useful to “short-circuit” instead, and allow exceptions to bypass the normal return value mechanism.
If respond
also returned exceptions, then we’d have to check the type at each middleware function. Since asynchronous handlers are a performance optimisation, we ideally want a performant implementation. raise
allows us to skip the normal processing steps in the same way that throw
does.
@weavejester thanks for the explanation, that makes sense 😉