This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-02-12
Channels
- # aleph (22)
- # aws (7)
- # babashka (17)
- # beginners (69)
- # chlorine-clover (9)
- # cider (2)
- # clj-kondo (3)
- # cljdoc (30)
- # clojure (113)
- # clojure-dev (30)
- # clojure-europe (11)
- # clojure-italy (2)
- # clojure-nl (16)
- # clojure-spec (1)
- # clojure-sweden (3)
- # clojure-uk (17)
- # clojurescript (77)
- # cryogen (12)
- # data-science (5)
- # datomic (27)
- # duct (2)
- # emacs (37)
- # fulcro (24)
- # graphql (2)
- # kaocha (1)
- # lambdaisland (27)
- # leiningen (4)
- # off-topic (15)
- # onyx (1)
- # other-lisps (3)
- # re-frame (94)
- # reagent (2)
- # reitit (20)
- # ring (1)
- # shadow-cljs (66)
- # spacemacs (5)
- # sql (59)
- # tools-deps (140)
- # vim (1)
- # xtdb (17)
Hey; Are there any recommendations for cljc time libraries? My main requirement right now is actually just preserving the type information across the wire from clojure (java.time types) to clojurescript via transit. i.e. preserving that a value is an OffsetDateTime or a LocalDate or a LocalDateTime or a Period etc… rather than actually doing anything with the information; other than displaying it via a format string. Though at some point I’ll want to sort and compare times of the same type; I probably won’t ever need much date/time arithmetic. Candidates as I see it are: 1. https://github.com/henryw374/time-literals 2. https://github.com/juxt/tick 3. https://github.com/henryw374/cljc.java-time Actually looking at these maybe cljc.java-time is what I want or just the time-literals?
Thinking the cljc.java-time and time-literals combo look ace.
I know
Yeah… I don’t need tick just yet… I really just need containers for the types
will include it when I need it though
I’m no expert; but if you don’t know any better and are doing a greenfield project; you probably want to first pick a grid-system/css-framework — and then either theme it yourself or find a theme for it. No idea what is currently in vogue (it changes every week) but some starting points to look at would be: - https://get.foundation/ - https://getbootstrap.com/ - http://getskeleton.com/ - https://material.io/design/
What you pick will most likely depend on what kind of site/app you’re building; and what features you need; e.g. responsive, grid, widgets etc.
ahh yes bulma was the other one… I was struggling to remember its name!
Hey friends, I have a little (beginner) question please about the way we manipulate js objects directly from cljs. I have the following object defined with the js literal :
dev:cljs.user!{:conn 2}=> (def student #js {"locker" 212
#_=> "grades" {"Math" "A",
#_=> "Physics" "B",
#_=> "English" "A+"}})
I would like to modify the “Physics” value and I thought I could use aset
like this :
dev:cljs.user=> (aset student "grades" "Physics" "my new-value")
"my new-value"
but then I end up with this :
dev:cljs.user=> student
#js {:locker 212, :grades {"Math" "A", "Physics" "B", "English" "A+"}}
dev:cljs.user=> (aget student "grades")
{"Math" "A", "Physics" "B", "English" "A+"}
The new value was not applied even though when I access the “Physics” value again with aget
, I have :
dev:cljs.user=> (aget student "grades" "Physics")
"my new-value"
did I miss something ?@U0DTAJS3Y from the docs aset and aget work with arrays but you have a map, the way I change the value in a map is
(assoc-in student ["grades" "Physics"] "my new value")
I was actually expecting some magic trick to happen with aset
since you could access nested structures with aget
if I am not wrong
The issue is that #js
is not recursive. You end up with a plain JS object that contains a ClojureScript vector under its "grades"
key`.
If you specify #js
in front of every map and vector, aset
would work. But you should not use it as it's designed to work only with arrays. There are other options:
1. Use multiple calls to goog.object.set
- will work with any keys
2. Use (set! (.. student -grades -Physics) "my new-value")
- will work only with keys that are valid symbols
3. Use https://github.com/binaryage/cljs-oops
4. Use https://github.com/mfikes/cljs-bean
5. Don't manipulate JS data structures at all - manipulate only CLJS data structures and then convert them to JS when needed (the least preferred solution if you care about performance)
thanks a lot for the explanation @U2FRKM4TW 🙂
I feel it’s written with react. but how is the css part, and how is the html structured? any framework involved?
CSS is very polished .. for the rest there’s not much going on .. I didn’t inspect the page to check if it’s react and personally I wouldn’t use it for something like that because I feel it’s overkill ..
Is there a more idiomatic way to write this in cljs (simplified):
(require '[js-joda])
(defmulti render-value type)
(defmethod render-value (.. js-joda -LocalDateTime) [ldt]
(str ldt))
If you're using shadow-cljs, you can use ["js-joda" :refer [LocalDateTime]]
require. But I have no idea if that would work with self-hosted CLJS.
ahh yes that does work. Thanks I forgot about that syntax; I’ve used it once before a long time ago
I’m following an highchart react example to build something in cljs, this is how I’m creating the component
[:> HighchartsReact {:highcharts Highcharts
:constructorType "stockChart"
:options stock-config}]
however it is failing because:
> The “constructorType” property is incorrect or some required module is not imported.
And it probably is because I haven’t imported the exporting.js module, but I haven’t been able to write it right, this is what it need to include,
require('highcharts/modules/exporting')(Highcharts)
how can I translate this to a cljs require?> it probably is because I haven’t imported the exporting.js module Why do you think that?
I had a normal chart working, that doesn’t need the constructorType property, and it was working, now that I want to test stockchart I’m following a different example, and in that example (https://stackblitz.com/edit/react-4ded5d?file=index.js) there are many things included, exporting is one of them, also in the reagent example with highcharts they include the exporting.js in the html directly (https://github.com/reagent-project/reagent-cookbook/tree/master/recipes/highcharts)
and currently I’m importing Highcharts like this
["highcharts" :default Highcharts]
["highcharts-react-official" :default HighchartsReact]
The highcharts-react examples uses:
import Highcharts from 'highcharts/highstock'
You use:
["highcharts" :default Highcharts]
Notice the difference?yes, I also tried
["highcharts/highstock" :default Highcharts]
yes, the same, right now I’m going to add
["highcharts/modules/exporting"]
I was confused, that exporting module is just to generate images from the chart, so it is not what I need, how ever it is still not working
I’m doing that, the problem is the string it is expecting in :constructorType
if I use the default :constructorType ‘chart’ it draws a chart
Do (js/console.log "Highcharts" Highcharts)
somewhere at the top level. Does it print out an object or undefined
?
but if I use :constructorType ‘stockChart’ it throws the error
(js/console.log "Highcharts" Highcharts)
=> undefined
["highcharts/highstock" :default Highcharts]
["highcharts-react-official" :default HighchartsReact]
Replace ["highcharts/highstock" :default Highcharts]
with ["highcharts/highstock" :as Highcharts]
. What does that log output now?
> Highcharts {product: “Highstock”, version: “8.0.0", deg2rad: 0.017453292519943295, doc: document, hasBidiBug: false, …}
why did work with :default ?
very subtle
yes, but you all need to import/require the correct highchart file (highchart, highstock, highmap, etc..)
@U4YGF4NGM The import does not translate well using the shadow-cljs guide, that's it. For some reason, this particular import works in JS (maybe transpiled, no idea), but not in CLJS.
when I look at the examples of Highcharts, there’s a lot of stuff they’re doing where they import additional files (not just "highcharts/highcarts"
and "highcharts-react-official"
, but many more modules) and then execute them as functions on the high charts object
I’ve read you two talk about importing high charts, but not about the supporting modules and applying them, so I’m just making sure we’ve already ensured we have those working
For instance, here’s an example of a stockChart: https://codesandbox.io/s/10yv629397
notice how it’s importing import StockTools from "highcharts/modules/stock-tools.js";
which seems relevant
None of the supporting modules are required. I got it working in CLJS with just the "highcharts/highcarts"
and "highcharts-react-official"
.
it’s interesting in the first example @U9BUENJ1F posted that specific import doesn’t show up, but maybe it’s rolled up into one of those other modules like 'highcharts/indicators/indicators'
or something
yes, as @U2FRKM4TW say, I don’t need any other module, the example you give uses a lot of GUI objects that I don’t need
Since the namespace rename forms don't work (https://clojure.atlassian.net/browse/CLJS-2371) is there any hacky way to rename a macro from an external library?
Is there any way to get the value of a variable in cljs? Looking for the equivalent of var-get
in clojure
Nevermind, .val
works!