nrepl

https://github.com/nrepl/nrepl || https://nrepl.org
FiVo 2021-01-05T14:31:42.100900Z

(def server (nrepl-server/start-server :port 35379))

  (def conn (nrepl/connect :port 35379))

  (nrepl/message (nrepl/client conn 1000)
                 {:op "eval" :code "(dotimes [i 3] (Thread/sleep 1000) (println (str \"==> \" i)))"})
;; => ()
  (def f (nrepl/client conn 1000))

  (f)
;; => ({:id "7a5fa37e-41ec-435b-b63c-5d58b611f4ac",
;;      :out "==> 0\n",
;;      :session "19c38d39-e6fd-4026-8aae-2f7a307c95d3"}
;;     {:id "7a5fa37e-41ec-435b-b63c-5d58b611f4ac",
;;      :out "==> 1\n",
;;      :session "19c38d39-e6fd-4026-8aae-2f7a307c95d3"}
;;     {:id "7a5fa37e-41ec-435b-b63c-5d58b611f4ac",
;;      :out "==> 2\n",
;;      :session "19c38d39-e6fd-4026-8aae-2f7a307c95d3"}
;;     {:id "7a5fa37e-41ec-435b-b63c-5d58b611f4ac",
;;      :ns "user",
;;      :session "19c38d39-e6fd-4026-8aae-2f7a307c95d3",
;;      :value "nil"}
;;     {:id "7a5fa37e-41ec-435b-b63c-5d58b611f4ac",
;;      :session "19c38d39-e6fd-4026-8aae-2f7a307c95d3",
;;      :status ["done"]})
Just some basic questions concerning the code above. The documentation of nrepl/client says "Most REPL interactions are best performed via message and client-session on top of a client fn returned from this fn." So I am just wondering what the usual workflow is when reading stuff from the client and why I shouldn't use the f directly as above. message and client-session both seem to take a message as argument. What is the usual way to read repsonses asynchronously?