Hello, this is noob question but i'm not that familiar with functional programming. Let's say we have Player (js-object) that has a bunch getter-setter (i.e., health, money, armour) which contains side effects. I have no privilege to modify the code of the object. How can i create a function that operate the object to be more pure? I have an idea to create a map that populated with the object values, and commit the changes after the function called, but that would be so expensive. Using a bunch operations of (.-health Player), (set! (.-money Player) 50) doesn't feels right either (some operation with js array really painful).
> some operation with js array really painful @raefaldhiamartya you may want to check out https://github.com/mfikes/cljs-bean - it won't make your code more "pure", but it could help you use more idiomatic clojure constructs without hurting performance as much as your idea of converting everything to ->clj and then ->js
I'm not sure what you mean by "more pure" here.
If you want to completely avoid side effects on the Player js-object, then never modify its fields, and use your own immutable object to represent players instead, is one possibility, but perhaps that isn't a useful suggestion if this Player object is needed because of its side effects it performs on other objects in some library.
Hello, I am writing a company human resource application, mainly grouping, filtering and charting data. Is there any good data cljs grid table library for this task? Thanks.
Ah, that is on my do list! I am thinking easier to start with a good JS data grid such as agGrid. Did you check out https://github.com/Kah0ona/re-datagrid?
thank you, I will have a try.
Does anyone recommend a particular http lib for cljs? I'm looking at https://github.com/r0man/cljs-http, but was initially hoping to find something that worked on the back end as well
Hello, i use https://cljs.github.io/api/cljs.js/#eval-strbecausehttps://cljs.github.io/api/cljs.js/#eval-stri need to send code to remote machine and evaluate the code there. i can get it working for simple operation, but i can't use any library even though the remote machine have compiled code (*.js and stuffs) before using the eval-str. any idea?
Hm, seems like this might be what I'm looking for https://github.com/JulianBirch/cljs-ajax Still curious if anyone has other recommendations though
Hi guys, I am just wondering and trying to find a way how to get the namespace name inside of a given namespace. In JVM clojure one can do (ns-name **ns**)
. In CLJS **ns**
is nil. I guess it has something to do how CLJS is compiled and executed in the JS runtime. Any idea?
try to read *ns*
via a macro, I believe you should be able to emit current ns name into cljs code
Where can I find documentation for use of the cljs compiler, i.e. how to invoke it from the command-line? More specifically, I am trying to invoke clj --main cljs.main <args>
where args would be either a build script or a .edn file. Right now I am looking at the cljs.cli/main.clj to try and make sense of it. Thanks!
clj --main cljs.main --help
?
Trying this:
(defmacro ns-macro []
`(ns-name ~*ns*))
but it doesn’t work.Thanks @darwin - I had tried this previously, but forgot to use deps.edn 😞
still new to this new .edn config setup
hmm, ~*ns*
is definitely wrong, either look at *ns*
or try (:ns &env)
or look what is available in &env
sorry, I don’t remember this from top of my head
What are some common ways to optimize transit output?
(ns leihs.borrow.lib.helpers
(:refer-clojure :exclude [ns-name]))
(defmacro ns-name []
`(quote ~(:name (:ns &env)))))
thanks!Anyone have any recommendations for a ClojureScript (or JavaScript I guess...) uptime status tool similar to something like rollbar but opensource?
Wow! Great trick. That's annoyed me for awhile too!
I would likely start by looking into the NPM ecosystem e.g. Axios and then, if you really feel they aren’t covering your needs, you can look to the CLJS wrappers.
Not familiar with rollbar. How exactly do you envision this integrating with your systems?
Rollbar just asks you to add a piece of JS to your web page that listens for the error
events.
Oh, you probably meant the backend part.
I just meant anything that will "check something to see if it's working and display a ❌ if it's not working"
/some/endpoint ✔️ /some/other/endpoint ✔️ /endpoint/no/worky ❌
possibly with graphs 😛
Hi folks, can I create an npm package with clojurescript (shadow-cljs perhaps) that I can then import in a typescript project?
It sounds like a web server monitoring and not a web app monitoring, so if you have access to that web server, something like Rollbar is not necessary at all since you can just detect API endpoint errors in code. Regarding graphs and monitoring in general - if you want to deploy something in your own infrastructure, Grafana is a commonly used solution. But there's no magic - you'd have to write something that actually collects the errors and sends them somewhere where Grafana can access them. Likely, something like this already exists - I just don't know about it.
Ah, of course - if you're using Nginx, it seems that Grafana can just read its logs: https://grafana.com/grafana/dashboards/5063
Yes. But there won't be any type information - it will be just plain old JS.
Huh, this documentation section is empty: https://shadow-cljs.github.io/docs/UsersGuide.html#_creating_code_npm_code_packages Perhaps because it's something that's subject to change. Maybe the next section is of some use. In any case, this is definitely a question for the #shadow-cljs channel.
ahhh yes sorry, this is actually for upstream sources we don't own but need to "audit"
If you have access to the logs, seems like Grafana should be able to handle that.
Thanks @p-himik! I’ll ask there
Yeah I guess I was trying to figure out what website uptime monitoring had to do with clojurescript, like if you needed a cljs lib you could run inside an app that was doing some intelligent monitoring or health check responding of its own. I've used pingdom and a buncha other services for basic "is it up" monitoring 🤷
Never used this but the dev behind it is pretty cool https://apex.sh/ping/
We don't have access to the log. This would be a preemptive/proactive polling kind of situation 😕
Apex Ping seems perfect -- except not opensource >.< my company isn't going to pay for that
Here's one https://sourcegraph.github.io/checkup/
Really depends on where you fall on the "we need this to be very accurate and reliable" vs "we don't want this to be complicated" scale I guess
def the later. Not a cljs tool but looks like a great tool!
You can get a long way with fetch
man, I cannot figure out how to use that checkup
tool 😅