aleph

alvinfrancis 2021-02-26T11:55:30.026600Z

Greetings, I have a quick question with aleph's http client. Is there a way to keep binding conveyance (like you get in other clojure core stuff)? Don't have much experience with it and wondering if it's even possible.

(def ^:dynamic *val* :a)
(binding [*val* :b]
  (->
   (aleph/get "<https://google.com>")
   (d/chain (fn [_] *val*))
   deref)) ; returns :a but want to keep :b

mccraigmccraig 2021-02-26T12:51:28.027900Z

@alvin.francis.dumalus no - deferred's result in callbacks under the hood, and the callback may be processed on a different thread, so dynamic bindings will not generally be visible

2021-02-26T16:37:03.029600Z

Bound-fn

mccraigmccraig 2021-02-26T16:44:06.031300Z

bound-fn might be ok in some simple cases, but as soon as you start composing with promises you are in trouble again - i've found it easier to stay away from dynvars altogether