Fork me on GitHub

Good Morning!


@folcon i don't like core.async for promise-like things - it's fine for streams. promesa is a good library - we've been using it concert with funcool/cats for promise stuff for ages


for one thing, error/exception handling is much more straightforward with promises than with core.async promise chans


Is there any good examples on using it? I've not worked with promises much. For context, I'm using it in a function within a re-frame app, I was initially hoping to just have it resolve within a function call, ie it returns to the caller, but it seems like I have to wait for the promise to resolve and use a callback, so for the moment I've had to add in a new re-frame event handler to act as a point to receive the callback from the core async channel. It's annoyingly made the logic there a lot more complicated 😞...


you would have the same issue with a core.async chan - API requests always have to be decomposed into an HTTP fx and a response-handling event


the way we deal with it is to have a generic API fx wich takes both a success event-template and an error event-template


then the promise handler or core.async take op handler either conj's the success value to the success event-template, or the error value to the error event-template and dispatches that


something like

{:api {:GET ""
       :success [:rx-thing]
       :error [:fail-thing]}}


Ok, good to know, I suppose I'll have to rethink that API then 😃...


whether you use core.async or promises, it's all just gloss over callbacks... that's the js life 😃


anyone have a nice way of preventing multimethod impls being removed from namespace :require decls by cljr-clean-ns ? i'm currently putting a def into the requiring namespace with a bunch of refs to vars in the impl namespaces, but it looks weird


@mccraigmccraig: I used to put (require 'foo.ns) forms beneath the ns declaration as a convention to avoid this; when I was including a namespace for a side effect. However I now follow the convention of putting a (:require [foo.ns]) form into the ns form itself… i.e. no :refer :as etc. Some newer tooling, like clj-kondo etc knows to interpret this style of require as one to leave alone, for side effects like multimethods protocol extensions etc… Can’t recall if cljr-clean-ns has been updated or not to handle it though.


cljr-clean-ns does still remove the apparently unused requires... i didn't know that clj-kondo didn't annotate an ns form with no :as though - that's nice


Yeah there was a big debate on how to handle it a few years ago here: I think the above is the best convention for handling it.


iirc quite a few tooling authors agreed on it too


huh, so they all agreed on missing :refer or :as meaning it's side effecting - but that behaviour hasn't made it as far as refactor-nrepl, at least not in v2.5.0


Yeah it’s not updated very frequently… Might be worth adding an issue for it, I suspect it would be a pretty simple patch to this function:


I've got an odd issue happening at the moment, perhaps someone has seen it before? I'm using figwheel through webpack and the source-code generated has got mangled names, but when I breakpoint in the debugger, the names provided aren't mangled at all. Any ideas what could be happening? The best I've got is that for some reason some of the code is being mangled, but not others and I have no idea why... I'm currently using lots of js-invoke to keep the names unmangled, but it's not exactly the best... Anyone else seen inconsistent behavior from minification?