This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-09-24
Channels
- # announcements (30)
- # asami (9)
- # babashka (37)
- # beginners (120)
- # calva (26)
- # cider (3)
- # clara (9)
- # clj-commons (7)
- # clj-kondo (17)
- # cljsrn (2)
- # clojure (32)
- # clojure-europe (56)
- # clojure-nl (1)
- # clojure-norway (13)
- # clojure-uk (4)
- # clojurescript (34)
- # conjure (1)
- # copenhagen-clojurians (8)
- # core-async (21)
- # cursive (2)
- # datahike (2)
- # datascript (5)
- # events (4)
- # fulcro (32)
- # graalvm (10)
- # heroku (3)
- # introduce-yourself (1)
- # jobs (2)
- # lsp (3)
- # luminus (1)
- # malli (8)
- # meander (15)
- # minecraft (1)
- # nrepl (2)
- # off-topic (57)
- # pathom (2)
- # polylith (35)
- # reagent (6)
- # reitit (8)
- # releases (1)
- # rewrite-clj (7)
- # shadow-cljs (21)
- # timbre (4)
- # tools-build (1)
- # tools-deps (33)
- # vrac (8)
Hi everyone, Just quick question, is there any way to get user location from the browser using ClojureScript?
https://developer.mozilla.org/en-US/docs/Web/API/Geolocation_API is probably what you’re looking for
Thanks for that info Sorry I am fairly new to Clojure would it be something like this (.. js/navigator -geolocation -getCurrentPosition ) in javascript i could do something like this, if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition); // (defn showPosition [position] (println position) ) How can I add a function like showPosition to this (.. js/navigator -geolocation -getCurrentPosition ) ? Thanks
some->
does cool stuff, but mainly here it automatically checks for nulls before trying the next step
It’s basically
(.getCurrentPosition (.-geolocation js/navigator) showPosition)
but with checking for nullsNote that what you use in showPosition
will be a js object, so js->clj
may/may not be of use here
I get 'electron is not defined' error when I try to require electron npm module in renderer process. It, however, works fine in main process. I'm using https://github.com/ahonn/shadow-electron-starter.
I updated electron and shadow cljs to latest versions
"electron": "^15.0.0", "shadow-cljs": "^2.8.110"
ShadowCLJS EDN -
{:source-paths ["src"]
:dependencies [[reagent "0.10.0"]]
:dev-http {8080 "resources/public/"}
:builds {:main {:target :node-script
:output-to "resources/main.js"
:main app.main.core/main}
:renderer {:target :browser
:output-dir "resources/public/js"
:asset-path "js"
:modules {:renderer {:init-fn app.renderer.core/start!}}}}}
electron tend to break stuff often. make sure you follow the electron documentation for the version you are using. they might have removed the global and made it a require or something
Looking at latest docs, ipc stuff needs to happen in preload script instead of renderer. I can get message on main sent from preload script now
Hi, I need some help with an advanced compilation issue. I have a very simple cljs app that uses DataScript:
(ns taia.core
(:require
[reagent.dom :as r]
[datascript.core :as d]
[re-posh.core :as re-posh]))
(def taia-schema
{:app/id {:db.unique :db.unique/identity}
:app/name {}
:app/type {}})
(def initial-db
[{:app/id :bunea.projects
:app/name "Projects"}
{:app/id :bunea.mudanza
:app/name "Mudanza"}
{:app/id :bunea.deuras-alex
:app/name "Deuras Alex Verano 2021"}])
(def conn (d/create-conn taia-schema))
(d/transact! conn initial-db)
(re-posh/connect! conn)
(defn home-page []
[:span "Hola"])
;; -------------------------
;; Initialize app
(defn mount-root []
(r/render [home-page] (.getElementById js/document "app")))
(defn ^:export init! []
(->>
(d/q '[:find ?id ?name
:where
[?a :app/id ?id]
[?a :app/name ?name]]
@conn)
(println :db))
(mount-root))
When initializing on the console I'd have:
:db #{[:bunea.projects Projects] [:bunea.mudanza Mudanza] [:bunea.deuras-alex Deuras Alex Verano 2021]}
When I used the advanced compilation with shadow-cljs I get:
:db #{[nil nil]}
shadow-cljs.edn:
{:source-paths ["client/src"]
:dependencies [[binaryage/devtools "1.0.3"]
[nrepl "0.8.3"]
[reagent "1.1.0"]
[datascript "1.2.2"]
[re-posh "0.3.3"]]
:builds {:app {:target :browser
:output-dir "client/public/js"
:asset-path "/js"
:compiler-options {}
:modules {:app {:entries [taia.core]}}
:devtools {:after-load taia.core/mount-root}}}
:dev-http {3000 {:root "client/public"
:handler user/app}}}
Thank you in advance for your help,
The source code is here: https://gitlab.com/danbunea/cljs.advanced.compilationUpdate: it seems to be related to Datascript. If I read the entire database:
(d/q '[:find ?e ?a ?v
:where
[?e ?a ?v]],@conn)
the results are:
:db #{[1 :app/id 1] [1 :app/name Projects] [2 :app/id 2] [2 :app/name Mudanza] [3 :app/id 3] [3 :app/name Deuras Alex Verano 2021]}
and on advanced:
:db #{[1 :app/id nil] [1 :app/name nil] [2 :app/id nil] [2 :app/name nil] [3 :app/id nil] [3 :app/name nil]}
having all the values nil. Still can't figure out whyI remember asking about something like this :) https://github.com/tonsky/datascript/wiki/Tips-&-tricks#externs-and-shadow-cljs
Hi guys,
how can I pretty print in the console?
I am using (cljs.pprint/pprint (-> e .-dataTransfer))
and the result that I see is: #object[DataTransfer [object DataTransfer]]
Thanks
What's the right way or what would be a good way to log extra data when a test fails?
I just wrote this macro as a replacement for is
:
(defmacro logging-is [expr msg & vals]
`(let [result# (t/is ~expr ~msg)]
(when-not result#
(js/console.group ~msg)
(try
~@(map (fn [v]
`(js/console.log ~v))
vals)
(catch :default ~'e
(js/console.error "Unable to log something" ~'e)))
(js/console.groupEnd))
result#))
Doesn't seem obvious why you'd want to do that, but that seems like the right impl to do it, unless you want to do more with the vals... Looking at is
though, maybe a dumb question, but could it be rewritten as a function? Is there any short-circuiting going on in the chain up to assert-expr
?
> Doesn't seem obvious why you'd want to do that The tests are executed in the browser - I can't easily just automatically break on a test failure and inspect everything in my cozy IDE. > Looking at `is` though, maybe a dumb question, but could it be rewritten as a function? No, at least not without losing a bunch of its functionality.