This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-11-11
Channels
- # beginners (104)
- # boot (14)
- # cider (10)
- # clojure (38)
- # clojure-australia (3)
- # clojure-dev (11)
- # clojure-spec (8)
- # clojurebridge (2)
- # clojurescript (50)
- # core-async (118)
- # emacs (3)
- # expound (2)
- # fulcro (39)
- # jobs (3)
- # jobs-discuss (17)
- # kaocha (2)
- # lumo (1)
- # off-topic (16)
- # onyx (1)
- # re-frame (1)
- # reitit (24)
- # shadow-cljs (14)
- # sydney (1)
- # tools-deps (14)
- # yada (1)
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
thanks @mfikes, perfect
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 https://blog.jeaye.com/2017/09/30/clojurescript-promesa/
Promesa is pretty nice, but it works with bluebird promises, not native JS promises.
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 https://github.com/clj-commons/secretary
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)
.promise
(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
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 https://aws.amazon.com/blogs/developer/support-for-promises-in-the-sdk/
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))
nil
cljs.user=> (cloneable? nil)
true
cljs.user=> (clone nil)
1
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
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
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
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
So, there is a way to suppress automatic browser launch if you are using the browser REPL
But I wonder if electron will connect to your REPL. Hmm. Here is the option https://clojurescript.org/reference/repl-options#launch-browser
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.
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
technically, NaN is a “special” number value, but it’s best not to think too hard about it
The guts of cljs.pprint/float?
looks useful, but I wouldn't require that namespace just for that fn
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: https://gist.github.com/mfikes/42063f0840c3f99b0ddfac141c130bac
@mfikes Thanks, it does make it clearer.