This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-03-02
Channels
- # announcements (25)
- # babashka (76)
- # beginners (74)
- # biff (36)
- # calva (11)
- # cider (5)
- # clerk (43)
- # cljs-dev (4)
- # cljsrn (12)
- # clojure (111)
- # clojure-austin (14)
- # clojure-europe (82)
- # clojure-nl (2)
- # clojure-norway (5)
- # clojure-uk (1)
- # clojurescript (36)
- # core-async (13)
- # cursive (30)
- # datomic (12)
- # fulcro (6)
- # honeysql (9)
- # hyperfiddle (73)
- # instaparse (3)
- # introduce-yourself (1)
- # membrane (40)
- # nbb (2)
- # off-topic (6)
- # other-languages (9)
- # polylith (33)
- # reagent (2)
- # reitit (7)
- # rum (7)
- # shadow-cljs (47)
- # tools-deps (10)
- # vim (11)
- # xtdb (16)
Live reloading seems to break sometimes. I'm in the electric datomic browser demo adding a new router endpoint, and when I make a new file anything in that file stops updating.
(ns app.trial
"must have datomic on classpath, and must load 'test ns"
;;#?(:cljs (:require-macros app.trial)) ;; I'm using a git dep on latest electric, no longer needed
(:require
[hyperfiddle.electric :as e]
[hyperfiddle.electric-dom2 :as dom]))
(e/defn Child
[]
(e/client
(dom/div (dom/text "hirt"))) ;; Changing the string has no effect on the browser
)
;; In the router in app.datomic-browser
(e/defn Child
[]
(e/client
(dom/div (dom/text "hidb"))) ;; Changing the string updates the browser
)
;; Referring to the second file, doesn't update properly
::test-page (history/router 1 (e/server (app.trial/Child.)))
;; Referring to this file, updates properly
::test-page (history/router 1 (e/server (Child.)))
This seems to be isolated to the datomic browser repo, since demos in the electric repo work fine as well. Any ideas?Ok, from your comment it seems you have this linked up against electric master, so you know about and have the latest hot code reloading changes
Ah, the :dev/always flag might be on the wrong file now ... checking
this looks like a typo on our part: https://github.com/hyperfiddle/electric-datomic-browser/blob/main/src/user.cljs#L1
compare to https://github.com/hyperfiddle/electric/blob/master/src-dev/user.cljs#L1
the meta comes first
i expect the view to update w/ the change in atom state, but some components are not hiding ... hmm
the view the current user is experiencing should live on the server, probably tied to the session var
Hi guys, I have a weird behaviour with datalevin
and pending. Sometimes, the catch
branch is not unmount. Here, a code to reproduce (https://gist.github.com/jeans11/3401cc6b23f0dd8f889971f6aa76fcac).
ty, we will investigate
Hi @UHZPYLPU1! Thanks for the repro! https://gist.github.com/xificurC/1cbc281dd49e7eb3c9f5adcba6382158. I'm not sure why your version glitches, but it's a tricky beast that catches Pending on the server and requests the client to render something, which will throw a new Pending! A better way to do this is to try/catch on the client, which resolves this issue
Really excited about Electric, and the demos are helpful. I apologize for asking this because it is so basic, but are there any walkthroughs or example repos on how to connect to a persistent DB? Being new to the Clojure world (let alone Electric) I'm still figuring out the DB options (Datomic, Datascript, XTDB) but these Datalog based DBs are part of what draw me to Clojure in the first place, and am leaning towards XTDB (not asking for XTDB specific instructions.) The standalone starter app's require statement seems to show a conditional #?(:clj allowing us to say what runs on the server side. I was suprised datascript is server side, I thought it was client side for some reason, and "meant to run in the browser." Is datascript appropriate for persistence in production, or would one of the others be needed? With Electric being automatically "multiplayer", what tells other user's UIs to update? When a bunch of different client UIs need to, update do they each re-read directly from the database, or does a websocket just tell them what pieces to update?
there is a rudimentary SQL tutorial linked in the readme, more robust examples coming soon. we use datascript in examples because it is zero setup but conceptually any db works mostly the same
we have a WIP XTDB starter as well, it’s a common request, will try to land it this week
re sql view updates - on mobile now, will write more in a few hours after my meetings this morning
Thanks I'll track down the SQL tutorial, and keep an eye out for the XTDB! Thanks again, really exciting work!
XTDB is basically as easy to get started as datascript, you can start a node with (xt/start-node {})
(for in-memory) to get started
I'm looking for a cooler SVG demo that highlights multiplayer, LMK if anyone does something with it
on the roadmap, we want it too
for now the best trick is to comment out the pages of your app you aren't actively working on, also use a fast computer (I know you mentioned you had two)
The compiler is doing a full program analysis on every change, so commenting out parts of the program you aren't developing is highly effective (Yeah i know this is dumb, sorry)
New maven release: {:mvn/version "v2-alpha-123-ga7fa624f"}
Changelog since 2-0:
• hot code reloading stability improvements. note: you MUST run shadow and your REPL from the same JVM; do NOT use shadow from nodemodules!_
• drop need for :require-macros in electric src files
• e/wrap
is now e/offload
, note the signature changed it takes a clojure thunk now, https://github.com/hyperfiddle/electric/blob/3fb66e9da5ee96a3efc81c56d2af8dd3b090486e/src-docs/user/demo_3_system_properties.cljc#L24
• zero config entrypoint – please compare to the https://github.com/hyperfiddle/electric-starter-app/blob/a8810accfdd96f82eefc2d976645538223a88de9/src/user.cljs#L7-L10 to see if any entrypoint boilerplate can be removed
• clojure deep def is now supported (for debugging)
• SVG support
• shadow-css is now supported
• added e/on-unmount
, see the https://github.com/hyperfiddle/electric/blob/3fb66e9da5ee96a3efc81c56d2af8dd3b090486e/src-docs/user/demo_4_chat_extended.cljc#L55. Notes: (a) this interface is going to change; (b) e/mount has been removed, https://github.com/hyperfiddle/electric/commit/dfcfe505e8142f06b5001d0eda00f7b406d1bb95
• async stack traces were improved
• fix: reactive exceptions no longer spam the console
• fix: pending bugs
• electric-goog-history example https://github.com/hyperfiddle/electric/blob/3fb66e9da5ee96a3efc81c56d2af8dd3b090486e/src/contrib/electric_goog_history.cljc, this is going to move and have breaking changes but we do commit to maintaining it somewhere
• misc fixes
• starter app and datomic-browser are updated
• clj-kondo config is exported
• legacy photon-ui and photon-dom are removed, you must upgrade
• introduced dom/on! optimized callback for fast events like https://github.com/hyperfiddle/electric/blob/3fb66e9da5ee96a3efc81c56d2af8dd3b090486e/src-docs/user/demo_reagent_interop.cljc#L70 (note: usage is going to change soon, the atom in this example is pure overhead)
You can just run a calva deps.edn + shadow repl, then load user.clj and run (main) from the comment to get a consolidated repl for calva.
Speaking of the starter app here: https://github.com/hyperfiddle/electric-starter-app
Thanks! In Calva, it is slightly less convenient to run deps.edn + shadow-cljs, than just shadow-cljs. But the latter isn't an option anymore, right?
@U09K620SG: You think this PR needs to be adapted to this new reality? https://github.com/hyperfiddle/electric-starter-app/pull/8
Using that starter app and calva I don't see any Electric options for a repl in calva, is that not in calva yet?
@UAB2NMK25, note that you can build in the step you mention to load user.clj
and run (main)
. Something we should consider adding to the repo, once I understand the change mentioned above.
Yes I got it working with this:
{
"calva.replConnectSequences": [
{
"name": "Electric App",
"projectType": "deps.edn",
"cljsType": "shadow-cljs",
"afterCLJReplJackInCode": "(require '[user]) (user/main)",
"menuSelections": {
"cljsLaunchBuilds": [":dev"],
"cljsDefaultBuild": ":dev"
}
}
]
}
Thanks for the pointer, was getting tired of having to manually start it from 'user.
(svg/svg
(dom/props
{:class "stroke-current flex-shrink-0 h-6 w-6"
:fill :none :viewBox "0 0 24 24"})
(svg/path
(dom/props
{:stroke-linecap "round" :stroke-linejoin "round"
:stroke-width "2"
:d "M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"})))
all the other props come thru okthanks! dom/props
https://github.com/hyperfiddle/electric/blob/dfcfe505e8142f06b5001d0eda00f7b406d1bb95/src/hyperfiddle/electric_dom2.cljc#L86 calls (set! (.-className node) ...)
which is a read-only field on https://developer.mozilla.org/en-US/docs/Web/API/SVGElement. We'll need to use classList
or some goog dom API instead
there is a complexity, svg/svg element is governed by the svg xml namespace, it's not clear if class is strictly speaking legal here, needs discovery
It seems it is legal, perhaps the issue is the intersection of the html xml ns and the svg xml ns and how to configure that properly
I don't know how setAttribute
works, so not sure. I think for now something like this would work as a workaround
(-> dom/node .-classList (.add "my-class"))
(e/on-unmount #(-> dom/node .-classList (.remove "my-class")))
Thanks for the help! I logged a ticket in our system. I'll wait for Geoffrey to help on fixing this since he has more expertise in this field
@U0ETXRFEW fyi i commented out the calva setup instructions until i verify the correct setup
@UAB2NMK25 you can auto-start by adding a line at the bottom of user.clj to call (main)
I like to be able to load any namespace without starting things. So having the call to main in the connect sequence makes sense to me.
yes, did it not work?
ha yes sorry about that it bites us all, hope to fix this spring
2nd question, how can I do like a "slideshow" of several images in clojurescript? would that be using timeout?
try using e/system-time-secs modulo N
does that make sense? (on mobile)
see the “blinker” demo actually