This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-10-20
Channels
- # ai (1)
- # beginners (17)
- # boot (27)
- # cider (2)
- # cljs-dev (64)
- # clojure (131)
- # clojure-austin (13)
- # clojure-dev (15)
- # clojure-dusseldorf (11)
- # clojure-france (45)
- # clojure-russia (19)
- # clojure-spec (66)
- # clojure-uk (22)
- # clojurescript (97)
- # core-logic (7)
- # cursive (5)
- # data-science (1)
- # datomic (92)
- # dirac (49)
- # emacs (1)
- # events (5)
- # funcool (10)
- # hoplon (79)
- # jobs (1)
- # jobs-rus (1)
- # lein-figwheel (1)
- # leiningen (3)
- # om (14)
- # onyx (35)
- # planck (2)
- # proton (1)
- # re-frame (21)
- # reagent (2)
- # ring-swagger (10)
- # spacemacs (10)
- # specter (18)
- # untangled (7)
- # vim (23)
Milestones, the smart project planning assistant, just got 0.3.0 with Natural Language Processing and GANTT! Please have a look on it here: http://turbopape.github.io/milestones/
I'm looking for a good technique for delaying loading my cljs app until a js library is ready.
In particular I'm experimenting with using Google Charts in a re-frame app. The dynamic loading is causing the problem. https://developers.google.com/chart/interactive/docs/basic_load_libs
My CLJS code is executing before the js lib is loaded so I get "Uncaught TypeError: Cannot read property 'DataTable' of undefined" when my code references js/google.visualizations.DataTable.
I guess I have to inject <script src="js/compiled/app.js"></script>
into the document in the library loaded callback. Feels hacky and if there were two libs like this it'd be extra hacky.
Can anyone recommend a better way?
@olivergeorge You're also loading your cljs compiled app dynamically? And the google chars library? Do I understand that correctly?
Thanks I'll check it out
@rauh no good reason to load my compiled app dynamically. Just needs to be delayed till the JS Libs have finished their setup work. Google charts have a dynamic load feature which complicates that. I guess the value it adds is avoiding a big page load when not all features are required.
The jsloader functions look handy. Thanks.
@olivergeorge Why not just do it with the callback like the link you posted describes it?
It can set a (reactive?) atom. Display "Loading..." when it's one value and use the chart library when it's the other value
That's a good idea for this.
I don't do re-frame, I have a mixin that does this for dynamic content in rum, that displays a spinner and a short message.
I'd like to go further and extend core.matrix protocols to DataTable class.
Meaning ensuring it's there before that namespace loads or wrapping that code into a fn.
You've given me good options. Thanks again.
Wanna see a thinking project planning program written in clojurescript in action? Head over here: http://turbopape.github.io/milestones/
@olivergeorge I made something like this a while ago:
(defn js-loader
"Load a supplied list of Javascript files and render a component
during loading and another component as soon as every script is
loaded. Arg map: {:scripts [] :loading 'component :loaded 'component}"
;; TODO turn scripts into a map with a global that can be used to check
;; if the script has been loaded before
[{:keys [scripts loading loaded]}]
(let [loaded? (reagent/atom false)]
(reagent/create-class
{:component-did-mount (fn [_]
(.then (jsl/loadMany (clj->js scripts))
#(do (js/console.info "Loaded:" (clj->js scripts))
(reset! loaded? true))))
:reagent-render (fn [{:keys [scripts loading loaded]}]
(if @loaded? loaded loading))})))
@olivergeorge it's reagent but if you use something else it can probably be ported easily
I'm using draft.js with clojurescript, and met a weird behavior around function call. I have a function that receive 3 arguments,
(defn find-link-entities [content-state content-block callback]
(js/console.log content-state)
(js/console.log content-block)
(js/console.log callback))
And let this function to be called by this line.
https://github.com/facebook/draft-js/blob/69890ed57b5f4256cc93ae8e9ea178296851a23e/src/model/decorators/CompositeDraftDecorator.js#L62
The result is the first argument has been ignored, the console prints content-block
as the first argument, callback
as the second function, and undefined
as the last argument.Sorry, this is not an issues ClojureScript relative. I found my draft.js (which from CDN) only call with two arguments..
@doglooksgood how is the function passed to draft?
Just provide it as a normal function. Draft's code has been changed, but its document hasn't been updated. According to its document, draft want this function with 3 arguments, but actually it's 2. So the problem solved. š
Howdy, I'm trying to use ReactBootstrap to add its NavDropdown with markup in top-level button. The problem is, content for that button is specified inside :title
of that component. As per this issue: https://github.com/react-bootstrap/react-bootstrap/issues/2264, it is possible to use markup there but I'm not sure how would that translate into cljs?
hey guys, someone already had this one ? Uncaught Error: No protocol method ReadPort.take!
I am doing the async clojurescript seminar of cognitect
(defn ex1 []
(let [clicks (events->chan (by-id "ex1-button") EventType.CLICK)
show! (partial show! "ex1-messages")]
(go
(show! "Waiting for a click ...")
(<! clicks)
(show! "Got a click!"))))
(ex1)
Waiting for a click is displaying but I got the No Protocol error
canāt understand why..
@baptiste-from-paris the error implies that clicks
may not actually be a channel
how is it possible ?
@baptiste-from-paris I do not know, you might have a made a typo while entering the code in
one way to check that clicks
is a channel is to (js/console.log clicks)
before the go
block to debug
ok, thx
Got [object Object] ^^
ok, found itā¦ type
#feelingStupid
yes sorry
Am I correct in thinking that (cljs.analyzer.api/ns-resolve ns sym)
finds a var defined in ns
, but not a var aliased or referred into ns
, as it only looks at the namespaces :defs
?
Maybe there's a better way to do what I'm trying to do. I have a form, and I know the namespace it came from. I'm trying to fully-qualify the symbols in that form according to that namespace, so things make sense.
Ideally, the form would already come fully qualified, by way of something like syntax-quoting
but in this case, the form is coming from the metadata map from defn
, which is automatically (non-syntax-)quoted.
@peeja it should handle aliases just fine, ns-resolve
should call the same machinery the compiler needs
How does it do that if it just looks at the :defs
map? https://github.com/clojure/clojurescript/blob/r1.7.170/src/main/clojure/cljs/analyzer/api.clj#L200
@peeja agree that ns-resolve
should match Clojureās behavior, ticket + patch (if you like) welcome
this is quite possibly a beginner question for clojurescript - Iām trying to set .style.display for an element like so
(defn hide-contact-dialog []
(aset (.getElementsByClassName js/document "contact") "style.display" "none"))
can someone help me out?what is the .. for? is there a good book/resource I can learn more about clojurescript from?
@mikepjb any good Clojure book will cover the language essentials which arenāt that different from Clojure
thereās isnāt a up-to-date print book on ClojureScript - but thereās lot of online stuff now
the trouble Iām having isnāt with clojure, Iāve written a few projects at work for it - Iām having quite a lot of trouble with javascript interop with clojurescript
invoke functions, set properties, interact with JSON values, invoke constructors - just this will take you a long way
I didnāt know you could even interact with goog, figured this was all to do with the closure compiler
@mikepjb this is good https://www.amazon.com/Learning-ClojureScript-W-David-Jarvis/dp/1785887637/ref=sr_1_2?ie=UTF8&qid=1477001079&sr=8-2&keywords=clojurescript
@jasonjckn thanks for the recommendation, iāll check it out
yes there's a chapter on javascript interop, the book covers a ton of material with shallow-medium depth
In my memories, they said it doesnāt cover Om.Next because too shiny when they wrote the book
@mikepjb I donāt know if you tried it, but https://github.com/magomimmo/modern-cljs is also nice, plus you learn about boot
if you donāt yet
I started using reagent because Iād heard it was simpler, it seems a lot of people still use om - is it a good idea to learn om? It seems like there is a lot more learning material for it. Are there any other reasons to learn om over reagent? Are there performance benefits?