This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-02-21
Channels
- # announcements (9)
- # babashka (45)
- # beginners (45)
- # calva (1)
- # clojure (40)
- # clojure-austin (16)
- # clojure-europe (16)
- # clojure-nl (1)
- # clojure-norway (35)
- # clojure-uk (4)
- # clojurescript (11)
- # conjure (3)
- # cursive (4)
- # datalevin (14)
- # datavis (1)
- # datomic (8)
- # emacs (6)
- # hyperfiddle (7)
- # introduce-yourself (3)
- # joyride (17)
- # missionary (16)
- # off-topic (2)
- # pedestal (9)
- # polylith (27)
- # re-frame (7)
- # reitit (1)
- # releases (1)
- # shadow-cljs (17)
- # sql (17)
- # tools-build (19)
- # tools-deps (15)
- # xtdb (15)
I am generating TypeScript types from the compiled JS in a CLJS project, but my multi-arity fns are compiled into JS fns taking the max number of args but then branching on arguments.length
. That makes the TypeScript compiler complain that I'm not supplying enough args when I invoke lower-arity versions of those fns in TS consumers of the CLJS lib. Is there a way to get it to use rest parameters (e.g. function sum(...theArgs)
) in the compiled JS output? Or is anyone aware of some other solution to that?
that part of CLJS is from a time before rest/spread existed in JS, so everything is still using arguments
. so no, there is no way to get this
OK, thanks for that info. That's what I would have bet money on being the answer. 🙂
whats the recommended way to use binding
with async flows? ie js/Promise.then
or reagent-render functions
yeah doesn't have to be binding itself, a workaround is fine
im thinking attaching a binding context to Promise instances, and providing a custom then function to wrap the callback to set/unset the dynamic vars over the call
thing is I have functions looking at <current selection> and applying changes there, and I want bindings to override this at the call site, with code in between which is completely unaware of this mechanism to the point it cant thread it through params
for reagent I hack around this with (set!) inside the render function, so nested calls which are always sequential get access to the data; its really ugly as a hack but also works; however for promises im unsure because the execution order is undefined
Essentially, what I'm looking for is "fiber local storage" but for async in javascript/clojurescript