This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-17
Channels
- # beginners (47)
- # boot (1)
- # calva (18)
- # cider (16)
- # cljs-dev (6)
- # cljsrn (14)
- # clojure (46)
- # clojure-dev (6)
- # clojure-italy (3)
- # clojure-sweden (2)
- # clojure-uk (1)
- # clojurescript (21)
- # css (1)
- # data-science (1)
- # emacs (2)
- # figwheel-main (2)
- # graalvm (11)
- # leiningen (3)
- # nrepl (19)
- # off-topic (1)
- # pathom (4)
- # re-frame (17)
- # reagent (4)
- # shadow-cljs (49)
I’d like to be able to send arbitrary messages back from my nREPL server process to the client. Any suggestions for how to handle this?
Currently the way this works in Cursive is that for a particular evaluation, I register a handler which handles values, out & err, errors etc, and associate the handler with the eval ID. When the eval is done I remove the handler so they don’t hang around forever.
However this doesn’t work very well for some use cases. For example, when working with CLJS when an eval results in a promise it would be nice to be able to send that value back to the client when the promise is fulfilled, but by that time the original evaluation is probably done and the handler will have been cleaned up.
I don’t want to keep all handlers around forever, but I’m not sure what a good expiry policy would be for them. Keep them around for n seconds? Keep the latest 100 around and expire them in a LRU fashion? I’m not sure.
> Currently the way this works in Cursive is that for a particular evaluation, I register a handler which handles values, out & err, errors etc, and associate the handler with the eval ID. When the eval is done I remove the handler so they don’t hang around forever.
@cfleming CIDER operates similarly. I just remove the handlers when a message is :done
and fallback to a default handler for responses that come for messages without a removed handler. I’ve been meaning to improve this for ages, but I never got to doing so.
> Cider provides middleware for this I think.
No, the handlers are purely a client concern. Every client decides themselves how to track responses and react to them - a handler in CIDER is just several lambdas that act on value
, err
, out
, etc for a particular message id.
> I’d like to be able to send arbitrary messages back from my nREPL server process to the client. Any suggestions for how to handle this?
I assume you want to associate some extra data with the requests and it would be attached to the responses, but I’m not quite certain I got this right.
@pez Output redirection middleware https://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider/nrepl/middleware/out.clj