clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
scythx 2020-09-17T01:49:28.006100Z

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

pithyless 2020-09-17T07:24:23.006900Z

> 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

❤️ 1
2020-09-17T05:48:26.006400Z

I'm not sure what you mean by "more pure" here.

2020-09-17T05:49:30.006600Z

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.

1
2020-09-17T12:25:23.010200Z

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.

kennytilton 2020-09-23T22:01:10.019800Z

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?

2020-09-23T22:29:52.020500Z

thank you, I will have a try.

ian_sinn 2020-09-17T12:53:54.011800Z

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

scythx 2020-09-17T13:00:04.015700Z

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?

ian_sinn 2020-09-17T13:01:10.015800Z

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

nitaai 2020-09-17T14:47:10.018Z

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?

2020-09-17T14:52:11.018100Z

try to read *ns* via a macro, I believe you should be able to emit current ns name into cljs code

2020-09-17T15:05:36.021400Z

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!

2020-09-17T15:14:50.021500Z

clj --main cljs.main --help?

nitaai 2020-09-17T15:25:00.021700Z

Trying this:

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

2020-09-17T15:27:49.022Z

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

2020-09-17T15:28:54.022200Z

still new to this new .edn config setup

2020-09-17T15:33:13.022400Z

hmm, ~*ns* is definitely wrong, either look at *ns* or try (:ns &env) or look what is available in &env

2020-09-17T15:33:27.022600Z

sorry, I don’t remember this from top of my head

2020-09-17T15:36:46.022800Z

this! https://stackoverflow.com/a/42324306/84283

Karol Wójcik 2020-09-17T15:37:51.023400Z

What are some common ways to optimize transit output?

nitaai 2020-09-17T15:59:42.024100Z

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

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

👍 1
unbalanced 2020-09-17T16:12:06.025300Z

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

unbalanced 2020-09-17T16:12:48.025400Z

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

athomasoriginal 2020-09-17T17:07:35.025600Z

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.

dpritchett 2020-09-17T17:55:02.027100Z

Not familiar with rollbar. How exactly do you envision this integrating with your systems?

p-himik 2020-09-17T18:44:54.027400Z

Rollbar just asks you to add a piece of JS to your web page that listens for the error events.

p-himik 2020-09-17T18:45:19.027600Z

Oh, you probably meant the backend part.

unbalanced 2020-09-17T18:46:23.027800Z

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

unbalanced 2020-09-17T18:46:59.028Z

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

unbalanced 2020-09-17T18:47:05.028200Z

possibly with graphs 😛

2020-09-17T18:49:40.029500Z

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

p-himik 2020-09-17T18:51:13.029600Z

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.

p-himik 2020-09-17T18:52:10.029800Z

Ah, of course - if you're using Nginx, it seems that Grafana can just read its logs: https://grafana.com/grafana/dashboards/5063

p-himik 2020-09-17T18:52:52.030100Z

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

p-himik 2020-09-17T18:54:43.030300Z

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.

unbalanced 2020-09-17T18:54:44.030500Z

ahhh yes sorry, this is actually for upstream sources we don't own but need to "audit"

p-himik 2020-09-17T18:55:55.030700Z

If you have access to the logs, seems like Grafana should be able to handle that.

2020-09-17T18:56:59.030900Z

Thanks @p-himik! I’ll ask there

dpritchett 2020-09-17T19:15:36.031300Z

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 🤷

dpritchett 2020-09-17T19:16:23.031500Z

Never used this but the dev behind it is pretty cool https://apex.sh/ping/

unbalanced 2020-09-17T21:09:59.032200Z

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

unbalanced 2020-09-17T21:10:18.032400Z

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

dpritchett 2020-09-17T21:33:35.032800Z

Here's one https://sourcegraph.github.io/checkup/

😍 1
dpritchett 2020-09-17T21:34:02.033100Z

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

unbalanced 2020-09-17T21:35:03.033300Z

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

Oliver George 2020-09-17T21:58:17.033500Z

You can get a long way with fetch

👍 1
unbalanced 2020-09-17T22:27:25.033700Z

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