clojure-uk

A place for people in the UK, near the UK, visiting the UK, planning to visit the UK or just vaguely interested to randomly chat about things (often vi and emacs, occasionally clojure). More general the #ldnclj
dharrigan 2021-02-05T07:16:47.174200Z

Good Morning!

djm 2021-02-05T08:24:44.175600Z

👋

mccraigmccraig 2021-02-05T08:25:04.175900Z

@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

mccraigmccraig 2021-02-05T08:25:59.176700Z

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

thomas 2021-02-05T08:31:00.176900Z

moin moin

2021-02-05T08:41:56.177100Z

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 😞...

mccraigmccraig 2021-02-05T08:48:15.177400Z

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

mccraigmccraig 2021-02-05T08:49:08.177600Z

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

mccraigmccraig 2021-02-05T08:50:51.177800Z

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

mccraigmccraig 2021-02-05T08:54:44.178Z

something like

{:api {:GET "<http://foo.com/api/dothing>"
       :success [:rx-thing]
       :error [:fail-thing]}}

jasonbell 2021-02-05T09:07:40.178400Z

Morning

alexlynham 2021-02-05T09:35:30.178500Z

morning

2021-02-05T09:36:06.178600Z

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

mccraigmccraig 2021-02-05T09:44:09.178800Z

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

2021-02-05T09:49:45.179Z

Yea...

mccraigmccraig 2021-02-05T15:35:35.180900Z

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

2021-02-05T16:07:29.183800Z

@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.

mccraigmccraig 2021-02-05T16:11:04.185400Z

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

2021-02-05T16:13:56.186200Z

Yeah there was a big debate on how to handle it a few years ago here: https://github.com/clj-kondo/clj-kondo/issues/241 I think the above is the best convention for handling it.

2021-02-05T16:14:37.186800Z

iirc quite a few tooling authors agreed on it too

mccraigmccraig 2021-02-05T16:23:57.188Z

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

2021-02-08T09:14:33.196600Z

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: https://github.com/clojure-emacs/refactor-nrepl/blob/dbafd6e686402dc020d7026e21ee556812fc51da/src/refactor_nrepl/ns/prune_dependencies.clj#L118-L122

2021-02-08T09:28:03.197100Z

Created issue for it here: https://github.com/clojure-emacs/refactor-nrepl/issues/292

mccraigmccraig 2021-02-08T09:43:05.197400Z

thanks @rickmoynihan 😃

2021-02-05T18:31:44.189600Z

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?