Is there any way to use cljc for a test ns?
I'm having problems with my require-macros
form in the ns form because technically it's clojure that's compiling it when it hits the compiler switch.
I see there are some libraries that manage to do it
I am using aws-sdk
specifically the dynamodb package using the scan command which returns https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-dynamodb/interfaces/scancommandoutput.html.
Does anyone know why accessing Items
like this (. result -Items)
would give the following compiler warning?
Cannot infer target type in expression (. result -Items)
You can mark result as a ^js. This should help
how do you call the scan? do you handle the promise correctly?
This is the whole block.
(def db (DynamoDBClient. #js{:region "eu-west-2"}))
(def table-name "tableName")
(defn items []
(-> (.send db (ScanCommand. (clj->js {:TableName table-name})))
(.then (fn [response]
(->> (. response -Items)
(map #(-> %
(unmarshall)
(js->clj :keywordize-keys true)))))
I am also slightly surprised that js->clj
does not seem to convert sets?
One of the items after the last line
{ ... :tags #object[Set [object Set]] ...}
you can add support for converting sets yourself. its not done by default because that requires a certain minimum language level
looks fine, try logging the response
. the docs say Items
is optional so who knows what it is 😛
The ^js
got rid of the warning, so I guess that’s ok?
> you can add support for converting sets yourself
Do you mean at an ad-hoc basis?
(extend-protocol IEncodeClojure js/Set (-js->clj [js-set options] ....))
ah ... misread your post. thought you were getting a JS runtime error 😛
yes ^js
tells the compiler this is a JS object and it'll not rename stuff in :advanced
> yes ^js tells the compiler this is a JS object and it’ll not rename stuff in :advanced Thank you 🙂 > (extend-protocol IEncodeClojure js/Set (-js->clj [js-set options] ....)) Ah awesome, I’ll give that a go
oy there are so many ui frameworks... re-frame, hoplon, fulcro, reagent, rum, and probably more. Rum seems the most minimal, reagent gives you an atom to work with but is otherwise just a react wrapper. fulcro and re-frame seem more full stack frameworks that use react as the view layer. hoplon seems to be its own thing entirely and not as big/active. re-frame enforces using a global atom across the app, is that common practice across the ecosystem? Their reasoning makes sense, but my understanding is that components will redraw when their atom changes, so that would mean redrawing the entire app all the time? Are there any frameworks that take more of a model view update approach similar to Elm? Not sure if this works well in ClojureScript. Maybe that's just a thing you do on top of Reagent/Rum.
Fulcro has similar approach, although it has high entry treshold so you will need to spend some time grasping the concepts. It is worth the time in my opinion. Also here on slack is #fulcro channel, https://fulcro-community.github.io/guides/tutorial-minimalist-fulcro/ and the author of fulcro made https://www.youtube.com/watch?v=wEjNWUMCX78&list=PLVi9lDx-4C_T7jkihlQflyqGqU4xVtsfi or https://book.fulcrologic.com/
@pepijndevos, re-frame is pretty good about minimizing refreshes if one takes care to not reference the app DB directly. ie, a subscription of a subscription will not trigger refreshes if the sourced subscription does not compute a different value when DB changes.
What do you mean with a subscription of a subscription?
As for alternatives, I am hoping to find a long weekend to get shadow-cljs to build my CLJS "React need not apply" framework. This is an intro to the JS version of that framework: https://tilton.medium.com/simplejx-aweb-un-framework-e9b59c12dcff
Hello. I have a figwheel-main project, which uses React (and some UI libraries) from `:foreign-libs` . When I made a copy of it (need to turn it in a similar project), in one way or another I've started receiveing an error `Uncaught TypeError: Cannot read property 'render' of undefined` with no possible way to fix. I tried to create new reagent project (`lein new figwheel-main hello-world.core -- +npm-bundle --reagent`) and take `core.cljs`file from there, but this didn't help either
> re-frame enforces using a global atom across the app, is that common practice across the ecosystem? Re-frame doesn't require or enforce a global atom, but it's the most common use case. It's a pretty common in clojurescript UI projects. > my understanding is that components will redraw when their atom changes, so that would mean redrawing the entire app all the time? Re-frame keeps track of the subscriptions used by different components so apps aren't fully rerendered (redrawing still wouldn't occur due to react and the underlying html engine) on every change. > Are there any frameworks that take more of a model view update approach similar to Elm? https://github.com/fulcrologic/fulcro has a fairly similar approach to model/view/update. My library, membrane, has an approach similar to elm, but it's focused on desktop UIs.
Ok, that just sounds like switching to shadow-cljs
that might be difficult if your code uses custom foreign-libs since shadow-cljs doesn't support those 😉
well that are just React and a couple of UI gadgets ("sortable" etc). so this should be good option 🙂