This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-12-08
Channels
- # adventofcode (283)
- # aleph (2)
- # announcements (1)
- # aws (12)
- # beginners (43)
- # calva (14)
- # cider (9)
- # cljsrn (1)
- # clojure (16)
- # clojure-kc (1)
- # clojure-nl (2)
- # clojure-uk (8)
- # clojurescript (55)
- # cursive (6)
- # datomic (6)
- # emacs (15)
- # jobs (1)
- # kaocha (5)
- # nrepl (13)
- # re-frame (2)
- # shadow-cljs (3)
- # spacemacs (6)
- # sql (10)
- # vim (13)
- # yada (5)
Anyone know of an example for js-interop-code for a fragment like this:
Sentry.withScope(scope => {
Object.keys(errorInfo).forEach(key => {
scope.setExtra(key, errorInfo[key]);
});
Sentry.captureException(error);
});
It is the Sentry.withScope(scope => ...
construct that eludes me a bitLooks like you're looking into writing a Sentry log appender? Maybe this will help: https://github.com/district0x/district-server-logging/blob/master/src/district/server/logging.cljs#L84
@U8L9BNAJE Does something like this not work?
(.withScope js/Sentry (fn [scope]))
Never mind. Saw someone else replied.
Seems like it expects just a function with a single argument, as a callback, so you can just pass in a normal CLJS function.
Typed on an iPad, please verify (.withScope js/Sentry (fn [scope] ,,,))
, replace ,,, with your code.
You might also be able to do (js/Sentry.withScope (fn [scope] ,,,))
. Not sure though.
Both approaches assume that Sentry is a global coming from somewhere else, not something you import. No idea about advanced compilation, externs and so on.
What ClojureScript libraries are available that take a very lightweight (in terms of deployment size) approach. React/Reagent/Reframe are excellent, but is there something simpler that is much smaller to deploy in a browser. Thinking something like https://lit-element.polymer-project.org/. Just curious, no actually need at the moment.
Thanks. We already looked at hoplon, it does take a long time to start up, so had assumed it was as big or bigger than react. Will create a deployment and check the resulting size. Thanks.
the time to startup is entirely dependant on your build are you using boot or lein?
I was just using the getting started example from the Hoplon website, which uses boot. I didnt realise hoplon worked with Leiningen
hey guys, has anybody tried to use externs inference
together with nodejs
namespace modules? I thought that by using the ns require, the compiler would automatically identify that as an interop type and use the dotform for interop inference but none of my namespace modules are getting inferred so my app breaks on production ๐
any ideas? I know that I am touching muddy waters ๐
Hey, trying to be more cross platform and was wondering what the problem with this is:
cljs.user=> (int \Z)
WARNING: cljs.core/bit-or, all arguments must be numbers, got [string number] instead at line 1 <cljs repl>
0
It seems like it should work, according to the documentation.this is probably related: https://dev.clojure.org/jira/browse/CLJS-2962
Okay, so I punted and now I'm using .charCodeAt
when in cljs and int
when in clj.
Now I have an issue with clojure.string/split
giving me an empty string at the beginning. Do I have to conditionally filter out the first element of a string when executing in cljs?
@clashthebunny Can you give an example of the clojure.string/split
behavior?
So, in Clojure, these are the same:
user=> (map keyword (filter #(not= "" %) (clojure.string/split "abcd" #"")))
(:a :b :c :d)
user=> (map keyword (clojure.string/split "abcd" #""))
(:a :b :c :d)
and in ClojureScript, they are different:
ClojureScript 1.10.439
cljs.user=> (map keyword (filter #(not= "" %) (clojure.string/split "abcd" #"")))
(:a :b :c :d)
cljs.user=> (map keyword (clojure.string/split "abcd" #""))
(: :a :b :c :d)
cljs.user=>
See the extra blank symbol at the beginning?
It's a known frustration with javascript.
It looks like ClojureScript has a separate function clojure.string/split-with-empty-regex to handle the case of an empty regex, which by someone's choice is written to return that empty string first.
Yeah, there is even a test for that case in https://github.com/clojure/clojurescript/commit/bf22dcca2e858811c8553ca9037e34a05b642121
I do not know the history there, but it might be so that ClojureScript's clojure.string/split is more similar to JavaScript behavior in the empty regex case?
What do people normally do to write cljc
then? Have a reader conditional that uses split-with-empty-regex
in cljs
?
Odd, given that (.split "abc" #"")
returns #js ["a" "b" "c"]
. There doesn't appear to be any immediately obvious rationale? (No ticket linked...)
Do I need to literally use "/(?:)/"
as my regex somehow?
If perf is no real concern, I would work around with something like (map (comp keyword str) "abcd")
Geeze, maybe ClojureScript was made to follow an older version of Clojure / Java: https://dev.clojure.org/jira/browse/CLJ-1312
Ooh! Thanks!
any handy references/tutorials for how to handle events (like .on('error')
and similar)
beginner cljs node problem if anyone has time..
(ns hello-node-async.core
(:require [cljs.core.async :refer [go <!]]))
(def result (atom nil))
(go (reset! result "hello"))
(println "waiting for result....")
(while (not @result))
(println @result)
I mean yeah, its basically just my way of awaiting the result of the go block. hello-node-async won't go to prod, don't worry!
A consequence of the single-threaded nature is that once the while
loop starts, if the result
atom is holding nil
, the reset!
call can never happen and it will deadlock.
@idiomancy FWIW, consider instead
(ns hello-node-async.core
(:require [cljs.core.async :refer[go <! put! chan]]))
(def result (chan))
(go (put! result "hello"))
(println "waiting for result....")
(go (println (<! result)))
yeah, totally! That's what I would have done in any real scenario anyway, it just bothered me that I didn't know why the while
strategy didn't work. It told me that there was something missing from my understanding
So I already posted this in shadow-cljs but I think people might be interested here too https://clojurians.slack.com/archives/C6N245JGG/p1544313429356100