Fork me on GitHub
#aleph
<
2021-02-26
>
alvinfrancis11:02:30

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 "")
   (d/chain (fn [_] *val*))
   deref)) ; returns :a but want to keep :b

mccraigmccraig12:02:28

@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

mccraigmccraig16:02:06

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