Fork me on GitHub

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


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.

thanks 3

> some operation with js array really painful @U018TG9AG8L you may want to check out - 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

❤️ 3

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


thank you, I will have a try.


Does anyone recommend a particular http lib for cljs? I'm looking at, but was initially hoping to find something that worked on the back end as well


Hm, seems like this might be what I'm looking for Still curious if anyone has other recommendations though


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.

Oliver George21:09:17

You can get a long way with fetch

👍 3

Hello, i use 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?


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


Trying this:

(defmacro ns-macro []
  `(ns-name ~*ns*))
but it doesn’t work.


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


(ns leihs.borrow.lib.helpers
  (:refer-clojure :exclude [ns-name]))

(defmacro ns-name []
  `(quote ~(:name (:ns &env)))))

👍 3
Lone Ranger16:09:48

Wow! Great trick. That's annoyed me for awhile too!


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?


Thanks @U08E3BBST - I had tried this previously, but forgot to use deps.edn 😞


still new to this new .edn config setup

Karol Wójcik15:09:51

What are some common ways to optimize transit output?

Lone Ranger16:09:06

Anyone have any recommendations for a ClojureScript (or JavaScript I guess...) uptime status tool similar to something like rollbar but opensource?


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.

Lone Ranger18:09:23

I just meant anything that will "check something to see if it's working and display a if it's not working"

Lone Ranger18:09:59

/some/endpoint ✔️ /some/other/endpoint ✔️ /endpoint/no/worky

Lone Ranger18:09:05

possibly with graphs 😛


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:

Lone Ranger18:09:44

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.


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

Lone Ranger21:09:59

We don't have access to the log. This would be a preemptive/proactive polling kind of situation 😕

Lone Ranger21:09:18

Apex Ping seems perfect -- except not opensource >.< my company isn't going to pay for that


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

Lone Ranger21:09:03

def the later. Not a cljs tool but looks like a great tool!

Lone Ranger22:09:25

man, I cannot figure out how to use that checkup tool 😅


Hi folks, can I create an npm package with clojurescript (shadow-cljs perhaps) that I can then import in a typescript project?


Yes. But there won't be any type information - it will be just plain old JS.


Huh, this documentation section is empty: 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.


Thanks @U2FRKM4TW! I’ll ask there