This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-04-25
Channels
- # announcements (3)
- # aws (6)
- # beginners (143)
- # boot (14)
- # calva (2)
- # cider (1)
- # clara (1)
- # clj-kondo (1)
- # cljdoc (4)
- # cljs-dev (50)
- # cljsrn (5)
- # clojure (61)
- # clojure-chicago (1)
- # clojure-europe (4)
- # clojure-italy (5)
- # clojure-nl (5)
- # clojure-spec (32)
- # clojure-uk (11)
- # clojurescript (166)
- # clojureverse-ops (2)
- # clr (3)
- # core-typed (1)
- # cursive (8)
- # datomic (21)
- # defnpodcast (1)
- # emacs (1)
- # figwheel (1)
- # figwheel-main (1)
- # fulcro (7)
- # graphql (7)
- # jobs (8)
- # leiningen (4)
- # luminus (3)
- # lumo (17)
- # mount (3)
- # nrepl (4)
- # off-topic (113)
- # pedestal (1)
- # re-frame (15)
- # reagent (2)
- # reitit (2)
- # shadow-cljs (75)
- # spacemacs (3)
- # sql (12)
- # tools-deps (44)
- # uncomplicate (2)
- # xtdb (15)
(ns foo ;;cljs
(:require ["esrever" :as esrever]))
(let [s "Lorem ipsum 𝌆 dolor sit ameͨ͆t."
a (clojure.string/reverse s)
b (esrever/reverse s)]
(js/console.log s)
(js/console.log a)
(js/console.log b)
(js/console.log (= a b)))
https://github.com/mathiasbynens/esreverUse of undeclared Var threedays.core/format
1 (format "%5d" 3)
^---
clojure fortmat doesn't work in clojurescript right?
i want to make 5 to 0005 how can i do this ?(defn card
[item]
[:div.holder {:component-did-mount (resetMsnryLayout)}
[:div.card
[:div.card-image
...
Thank you. I searched on github and I found some sample codes. I'll try to implement now.
I have a memory leak in my app, and I wanted to know if anyone has some advice on how to tackle the problem? The leak only appears on Windows
@neo2551 need a lot more information to be helpful - did you confirm via Chrome/Firefox dev tools that you're not leaking there? what version of IE are you talking about? And is the observed behavior in IE a crash?
It happens on Firefox on Windows
But kit Firefox Linux
@dnolen thanks a lot for helping. I will try to do more thorough test with multiple browser first.
What are the common cause of memory leak in cljs? (With reagent/re-frame)
Thanks :)
@neo2551 usual issue is to do some kind of operation that involves an infinite lazy sequence and then realize it - which of course will just eat up memory
But if this is the case, it would consume the memory super fast?
Thanks. I have an app that loops events.
Thanks I will search!
And also thanks a lot for your talks! They are really inspiring
I wish we had the slides for the one when you talk about simpler tools.
@lilactown I constantly get Use of undeclared Var hx.hooks/useEffect
When i try to utilize your library
I mean it’s not that the error is wrong just curious why it’s not occurring for me 😛
yeah, and it’s barfing because I also have some CLJS-specific code that’s not in a reader conditional
but just ensure that you’re pulling that one when shadow-cljs downloads the dependencies
i think it does some caching and I’m not sure how to invalidate it for snapshots (if it’s required)
Downloading: lilactown/hx/0.5.0-SNAPSHOT/hx-0.5.0-20190425.151107-2.jar from https://repo.clojars.org/
thanks @lilactown
😄 all fixed. thanks for the report! happy to help!
anyone know of a good way or workaround to do with-out-str
on console.log?
Presumably the console entries are stored somewhere, is there some way to access them?
Alternatively, does anyone know what the console
uses to display object properties? like some kind of format function I can call on MouseEvent
that would return me the string that is displayed in the console with console.log
yeah, but thats the inverse of what I need. I want the value that is generated from the inputs, not the inputs to the function
well, I would be okay with that. at least I could parse it. the issue I have is that attempting to serialize an event with JSON.stringify doesn't work. circular references etc prevents it from formatting. console.log deals with that though, and I wanted to capture its output. but I mean ideally id really just like a way to serialize a dom event
well, using output from console.log for this would be a brittle idea (browser vendors can change that output anytime), instead remove circular references or stuff which is causing troubles prior calling stringify on it
btw. console strings you print are not stored anywhere accessible, at least in chrome, they are sent over into browser engine, they are not kept in js environment
couple of different solutions here: https://stackoverflow.com/questions/11616630/json-stringify-avoid-typeerror-converting-circular-structure-to-json
I ended up just doing this:
(defn capture-event [e]
(let [keys (js->clj (js-keys e))]
(zipmap (map keyword keys)
((apply juxt (map (partial partial #(aget %2 %1)) keys)) e))))
@ghadi you can hook into warnings via :warning-handlers
. I am experimenting with this using https://github.com/emezeske/lein-cljsbuild. Here’s a link to my playground warning-handler: https://github.com/lread/rewrite-cljs-playground/blob/cljc-spike-2/test/rewrite_clj/warning_handler.clj which is specified here: https://github.com/lread/rewrite-cljs-playground/blob/cljc-spike-2/project.clj#L36
I don't see it listed here https://clojurescript.org/reference/compiler-options
## 1.8.40
### Fixes
* CLJS-1603: Only warn for misspelled comp/REPL opts
* :warning-handlers missing for known compiler options
* CLJS-1592: Self-host: Robustness for core tests
*
It is a clojurescript thing http://cljs.github.io/api/compiler-options/#warning-handlers
lein-cljsbuild made it easy to specify a warning-handler, so I took that route for now.
https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/closure.clj#L206
nice! does :warning-handlers resolve a symbol into a function? or do you need to supply a function from code?
no, that was what I found a bit awkward with it and why I started my experiment with lein-cljsbuild which does resolve for you.
FWIW, here’s where lein-cljsbuild helps out with the setup of warning-handlers: https://github.com/emezeske/lein-cljsbuild/blob/master/plugin/src/leiningen/cljsbuild.clj#L126
I wonder if :watch-fn
:watch-error-fn
and :warning-handlers
could use requiring-resolve
I don't know how that interacts with self-hosting... but it would be nice for build automation
prepl does this aleady with its own version of requiring-resolve
https://github.com/clojure/clojure/blob/master/src/clj/clojure/core/server.clj#L263-L270
@ghadi I don't see any issue for self-hosting - and even if there were that would be considered separately
patch welcome for this and I completely agree - would be simple - I think the only consideration here would be making sure this doesn't tie us 1.10 or something like that
Is there a guide or tutorial to resolving js promises in cljs? I know that the promise will never reject
@mv i've been successfully using funcool/promesa
with js promises for quite a while http://funcool.github.io/promesa/latest/
no stdlib way afaik, other than using the completion callbacks to put the resolution onto a core.async channel
(-> (returns-a-promise-of-a-thing)
(.then (fn [thing] (do-something-with-thing thing)))
?on the topic of promises — anyone had to implement something to run multiple promises sequentially?
well, sure, if you only want to resolve a single promise - when you want to compose chains of them with sensible error handling you might want a lib
yes @martinklepsch exactly that
@martinklepsch not sure I totally understand. do you mean, given a collection of promises, that you run each one after the other, feeding result of one into the next?
we use the promesa impl of the funcool/cats
promise monad context a lot - i really like it - the monadic bind syntax makes for very comprehensible code
more like this
a().then(b).then(c).then(function(result) {
// all are done here
});
I don't actually care about the result of the previous run but yeah, first promise should resolve before second is "started"
@martinklepsch (cats.core/mlet promesa-ctx [a (thing) b (other-thing) c (ya-thing)] (return (x a b c)))
it's hard to know what exactly you want to happen different than writing out that promise chain exactly
oh right, sorry — I want to do this in a map
like interface over a sequence of items.
which makes it hard to do it with syntax constructs like mlet
etc
so you could do
(defn chainp "Chains a promise-returning function to a promise"
[p1 f]
(.then p1 f))
(.then (reduce chainp (js/Promise.resolve) [a b c])
(fn [result]
;; all are done here
))
or something like >>=
- https://github.com/funcool/cats/blob/master/src/cats/core.cljc#L889
you're right, it's really that simple I guess. 🙂
Argh, how do I set element 0 of a js array again? (set! (nth (.-data obj) 0) "something-else")
doesn’t work
Filed https://dev.clojure.org/jira/browse/CLJS-3074 I might not have the time to look at this, so it's up for grabs by any motivated party! @dnolen