This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-10-02
Channels
- # announcements (15)
- # aws-lambda (1)
- # babashka (2)
- # beginners (25)
- # calva (2)
- # cider (6)
- # cljfx (6)
- # clojure (24)
- # clojure-boston (1)
- # clojure-dev (2)
- # clojure-europe (31)
- # clojure-uk (2)
- # clojurescript (48)
- # community-development (4)
- # conjure (1)
- # datahike (4)
- # datascript (10)
- # datomic (1)
- # deps-new (1)
- # fulcro (10)
- # juxt (1)
- # malli (7)
- # missionary (1)
- # nrepl (2)
- # off-topic (2)
- # other-languages (5)
- # polylith (4)
- # random (1)
- # react (2)
- # shadow-cljs (9)
- # tools-deps (21)
Hey folks, I’m trying to write a macro that wraps secretary’s defroute
and adds a check to the auto-generated URI function, here’s what I’ve got:
(defmacro safe-defroute2
[name & body]
`(do (secretary.core/defroute ~name ~@body)
(alter-var-root
(var ~name)
(fn [f#]
(fn [params#]
(when (every? identity (vals params#))
(f# params#)))))))
But I see now that alter-var-root
is clojure only, any ideas how I might do something similar in cljs?
create an extra secondary name for the defroute
and create a defn
that does the checks and that calls the defroute?
so you end up with (defroute foo* ...)
and (defn foo [params] (check params) (foo* params))
Is it possible to put a definition like "@keyv/sqlite" "^2.0.2"
into :npm-deps
or does the key have to be a keyword?
Hi, I am using reagent (with re-frame), and I have task for adding some attributes to elements, so E2E tests can easily query elements on page. Is there an easy way to add some attribute resolver, so I dont have to call some function in every single element? I've looked into reagent compiler but I guess my thinking about problem is wrong.
I would imagine that I can output some element like [:div {:test-anchor "x"}]
and for production, html output is single div without any special attribute, but for testing environment there is some test attribute like data-test "x"
.
Only solution I am able to think about is just wrap all elements into some component handling this function, is my thinking wrong?
Assign clear identifiers to all the things you need to identify - even in production. You might think that there's little sense in it, but it is immensely useful with app metrics solutions that track what users do. E.g. Rollbar will clearly tell you what buttons were pressed and what inputs were changed right before some error on the page.
Promise.resolve
flattens promises when the value resolved is another promise. But in #nbb the result of an evaluation can be a promise which I don't want to resolve. How can I create a promise that resolves to another promise object, not to the result of that promise?
Have never seen anyone wanted to do it. Could you please elaborate why?
If you could also provide a snippet
I explained why. If someone evaluates 1
the result should be a promise that resolves to 1.
If someone evaluates (js/Promise.resolve 1)
the result should be a promise that resolves to a promise, not to 1
.
See #nbb for more context.
Understood
The reason I'm wrapping "normal" values in promises is that some evaluations are expected to return promises (the namespace handling): so all results should be promises to normalize the API. But sometimes the evaluation should really be a promise within a promise since what the user was evaluating was a promise.
Thanks. This totally makes sense. Let me think for a few minutes
Probably the easiest way would be to create a Thenable alike type.
That way it would be easier to differentiate the Promise and your custom type. Actually not even Thenable since resolve will unwrap the value as well.
I don't know though if you have a control of calling the .then method in the eval context
If yes then this is one of the possible solutions
Who is wrapping namespace handling in promise?
Can you wrap it in fake Promise?
Nested promises always flattens in JS
Does namespace handling has to be done asynchronously?
Hmm. But the imports are only async in the situations like x = import("something") 😮
The import sth from "something"
is not async AFAIK. What is the reason you prefer async import?
this is a different discussion, I have already spent many hours discussing this with many people. let's take this as an assumption for now. the reason is that nbb uses dynamic import.
Maybe I'm asking just a stupid questions 😂
Sure. Try wrapping the value. Seems like the easiest thing you can do
Or callbacks, which are a little bit faster than Promise, but in CLJS it will be full PITA