This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-04-09
Channels
- # announcements (1)
- # architecture (20)
- # aws (22)
- # babashka (41)
- # beginners (191)
- # chlorine-clover (66)
- # cider (19)
- # clj-kondo (54)
- # cljs-dev (15)
- # cljsrn (78)
- # clojars (1)
- # clojure (148)
- # clojure-android (4)
- # clojure-europe (7)
- # clojure-gamedev (15)
- # clojure-germany (6)
- # clojure-losangeles (46)
- # clojure-nl (23)
- # clojure-survey (3)
- # clojure-uk (46)
- # clojurescript (24)
- # conjure (21)
- # cursive (21)
- # data-science (11)
- # datomic (5)
- # events (2)
- # fulcro (28)
- # garden (32)
- # joker (2)
- # kaocha (6)
- # lambdaisland (4)
- # mount (2)
- # off-topic (11)
- # pathom (10)
- # pedestal (13)
- # re-frame (7)
- # shadow-cljs (15)
- # spacemacs (21)
- # specmonstah (1)
- # wasm (1)
- # windows (1)
- # xtdb (37)
Hope everyone is healthy and safe. Has anyone worked with “worldwind-react-globe” or “worldwindjs”? I’m not understanding how to work with renderable layers and my Google-fu isn’t finding me any examples I can successfully translate to CLJS
I'm running this example in clojurescript: https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_canvas_drawimage And I have the following. (Ignore what segmentation or segmented means):
(def run-segmentation (with-meta identity {:component-did-mount #(dispatch [:run-segmentation])}))
[run-segmentation
[:div
[:canvas {:id "img-editing"}]
[:img {:src "/run-segmentation" :id "segmented"}]]]
The css file:
#segmented {
border: 1px solid green;
height: 277px;
width: 220px;
}
#img-editing {
border: 2px solid blue;
width:240px;
height:297px;
}
The event listener:
(reg-event-db
:run-segmentation
(fn [db _]
(set! (.-onload img)
(fn []
(let [c (js/document.getElementById "img-editing")
ctx (.getContext c "2d")
img (js/document.getElementById "segmented")]
(.drawImage ctx img 10 10))))
db))
But the output isn't what is expected:
What am I doing wrong?running a reagent project in atom and it will only run a CLJ repl even when I switch to a specific cljs namespace it wont evaluate any CLJS or js interop. Anyone got any advice? Wont work in emacs either
ClojureScript doesn't have a format
function right? https://cljs.github.io/api/cljs.core/format What's the best alternative?
Perfect thanks!
Oof you're right, it's right there!
having a hard time understanding how to parse json in practice. the js->clj tutorial makes sense but I have all of the JSON in a different file. is there a way to pass my .json file into the function.
sorta like this: (.parse js/JSON <file.json>)
you need to read the file in somehow, either via a network request (in a browser) or via reading form disk (node.js)
you can potentially read it at compile time using a macro depending on your use case
yes if it is in your project directory, you need to serve the file somehow if you want to read the file at runtime.
if you want to read the file at compile time, that can also be done but is more complicated
is this a web app or a nodejs program?
I imagine you have some sort of public
dir that you’re serving html/css/js files from
e.g. if you have the file structure:
src/
resources/
public/
index.html
js/
css/
something.json
then in your code you can do:
(-> (js/fetch "/something.json")
(.then #(.json %))
(.then js->clj)
(.then prn))
and it will fetch the something.json
file, convert it to a CLJS data structure, and print it to the console/REPL