Fork me on GitHub
Joel Elkins00:11:45

I'm doing an ajax call that returns a BigInt, which gets translated by transit into cognitect.transit.BigInt on the cljs side. What can I do with that? Coercing to a string would be fine but how?


@joel032 if bigint is a BigInt, then (.-rep bigint) will evaluate to its string representation


What's the state of the art for interacting with Promises currently? I'm open to the method described at this link (which I think could be made cleaner with helpers for specific uses) but it'd be nice to get a second opinion


Promesa is pretty nice, but it works with bluebird promises, not native JS promises.


I don't know of anything like it that works with native promises though


Yeah, it's the littering of js/Promise.resolve through code taking that approach (which I've used myself in a couple of places in a current project) that's unappealing


anyone running into problems with secretary on cljs 1.10.439, it now lives on in


Hello everyone, is there a clojurescript library for accessing the DynamoDB API? I’ve found hildebrand is not developed anymore


Hello @rastandy! I’m not aware of Clojurescript library but I recommend using the official AWS Node.js SDK via interop. The SDK supports Promises and you get nice ergonomics with Promesa library. Here’s a small example with SNS but it would be similar with DynamoDB.

(ns example.core
  (:require [cljs.nodejs :as nodejs]
            [promesa.core :as p]))

(def AWS (nodejs/require "aws-sdk"))
(def sns (new AWS.SNS))

(def params #js{:Message     "some message"
                :PhoneNumber "+123456789"})

(-> sns
    (.publish params)
    (p/then (fn [resp] {:result resp})))


@valtteri Thank you very much, I think I will follow your recommendation, the code seems clean enough with the Promesa library

👍 4

Pro tip: Promesa uses Bluebird promises under the hood. You can tell AWS-SDK to also use Bluebird instead of native JS promises. It works also with native promises, but you get better performance and some advanced features with Bluebird. If you’re interested see “Setting Promise Library” section


why isn’t nil reduceable? in cljs?

(clojure.core/reduceable? nil)


also these ones:

cljs.user=> (iterable? nil)
cljs.user=> (seqable? nil)


seqable? matches Clojure behavior for nil


cloneable? seems to fall into the same category as reduceable? and iterable? (ClojureScript-specific protocol tests, without implying any further semantics)


The return values for each seem to match what happens with nil:

cljs.user=> (-clone nil)
No protocol method ICloneable.-clone defined for type null:
	cljs.core/missing-protocol (cljs/core.cljs:316:4)
	cljs.core/-clone (cljs/core.cljs:567:17)

cljs.user=> (-reduce nil +)
No protocol method IReduce.-reduce defined for type null:
	cljs.core/missing-protocol (cljs/core.cljs:316:4)
	cljs.core/-reduce (cljs/core.cljs:692:4)

cljs.user=> (-iterator nil)
No protocol method IIterable.-iterator defined for type null:
	cljs.core/missing-protocol (cljs/core.cljs:316:4)
	cljs.core/-iterator (cljs/core.cljs:867:15)


The answer can also depend on runtime:

cljs.user=> (extend-type nil ICloneable (-clone [_] 1))
cljs.user=> (cloneable? nil)
cljs.user=> (clone nil)

Roman Tsopin18:11:59

Hi all, is there way to start cljs.main REPL with electron target? The problem is it has something from browser and something from node. Can’t figure it out how to mix it


@romantsopin there’s a few Electron starter git repos floating around. I don’t know how up-to-date they are


It would involve two separate REPLs, right?


yes, it looks like they have separate builds and REPLs for the node side vs browser side


you’d need to have a build/REPL for the “main” process” and another for the “renderer” process


seems simple enough

Roman Tsopin19:11:50

I have a problem with renderer side, it’s mostly like a browser but it uses some node stuff too, for example file system and I don’t know how to require electron from browser side properly

Roman Tsopin19:11:39

I mean, it’s all good when I just “watch” the file, but when I try to start REPL - it expects me to launch browser and browser fails on node part


Oh, right...


So, there is a way to suppress automatic browser launch if you are using the browser REPL

Roman Tsopin19:11:43

Yep, but then it’s waiting for manual launch on the expected port


But I wonder if electron will connect to your REPL. Hmm. Here is the option


Right. I don't understand the electron model well enough. I've used Electron with Figwheel in that case, but it ends up making an altogether different connection.

Roman Tsopin19:11:57

Yes, if I could somehow connect to electron directly, but can’t figure out the proper way to do it. Thanks, will look at Figwheel. Just wanted to get simplified model first


Has anyone else noticed that number? return true for ##NaN?

Alex Miller (Clojure team)22:11:42

technically, NaN is a “special” number value, but it’s best not to think too hard about it


Indeed. What is the recommended way to check for strictly real numbers then?


(js/isNaN ##NaN) could be used to form a solution


infinite? is another useful predicate in this area


The guts of cljs.pprint/float? looks useful, but I wouldn't require that namespace just for that fn


I used (js/isNaN ##NaN). Called it number2?. Thought is was a bad name.


I guess I’ll continue to use that.


real? or finite?. Hmm


As posted on IRC : With the new cljs update (1.10.439), I have macros emmitting a warning on private var use (in the same namespace... tho I guess the macros are clj and the rest is cljs...). Should I simply stop using private functions inside macros?


@frozenlock If there are no perf concerns you can use the var special (or its #' reader equivalent) to access private vars


If perf is a concern, you can use a bit of a hack to use js interop to access the private var from the macro


By the way, even though a macro might appear to be accessing a var in its own namespace, I suspect if you look at what is really going on, the macro is being expanded in another namespace, which produces code that accesses the private var; the same issue would occur in Clojure, but the access would be denied there


Hmmm the macro works fine in clojure.


I'll try to expand it.


@frozenlock Here is a gist of the example I had in mind, failing in Clojure:


@mfikes Thanks, it does make it clearer.