Finally, I had the time to polish and publish the three.js bindings source code. You can add it as a dependency and use it as a library or clone the repo and play with it. https://github.com/HendrikLevering/electric3-threejs
Is the ChatMonitor in the fiddle and starter app suppose to work? After clicking the auth link I can see that a cookie was created but I still don't get logged.
you want to e/watch the datomic connection, not directly but rather you need to implement the tx-listener API - search history here and in missionary for some snippets
determining which queries to maintain is "your problem" (choose a streaming database if you want realtime queries everywhere) BUT missionary and electric give you the concurrency power you need to build an adhoc solution
Same problem here: cookie gets set, but I don't seem to get logged. The rest of this conversation is way above my head for now π
action required, entrypoint fix is in userland (starterapp entrypoint) not electric itself, see https://clojurians.slack.com/archives/C7Q9GSHFV/p1738591790727399
Ran into the same problem when trying to inject variables into the request via middleware for consumption by my Electric code.
we're fixing, sorry
if you need an immediate workaround you can inject by global side effect
No worries. Yeahβthat's what I'm doing. Running into other issues getting streaming working with Datomic. Reading Missionary docs and poking at the Datomic browser code.
I prefer the blocking APIs, e/Task and ex/Offload-latch give you primitives to move work to a thread and await
you can of course be macho and integrate the streaming APIs
(d/datoms db :aevt :db/txInstant) seq-consumer (m/reduce conj ()) e/Task is hitting an async datomic API but immediately just waiting for it to finish before handing off to the UI
What I'm building right now is fairly basic CRUD. But I would like to see entities I create in the REPL flow straight through to the view in the browser.
looks like e/http-request is always nil
same issue on https://electric.hyperfiddle.net/tutorial/chat_monitor
yeah thanks we can repro
Interesting the pattern of putting print statement in let forms doesn't work in e/defn:
(let [something 1
_ (println 'something something)]...
won't print anythingIn Electric v3 let statements do not execute the right hand side of a binding unless you use its value somewhere else
So this will print:
(let [x (println 42)] x)
but this wont:
(let [x (println 42)])If I remember correctly, then the reason is to avoid accidentally data transfer between client and server.
(e/server (let [x (e/client 42)] (e/client (println x))))
Here the compiler nows that the symbol x is only used on the client, so no transfer from client to server.There were issues, that destructuring in let bindings caused accidentally data transfer. I am not sure, if these have been solved or if the advice is to avoid destructuring if let spans client/server boundaries.
(let [x (prn 1)] x ...) will sample the prn, see https://electric.hyperfiddle.net/tutorial/fizzbuzz
with respect to destructuring, you just have to be aware of which site is doing the destructuring. Broadly speaking, the goal of Electric is not to forget about client/server, but to give you tools with surgical precision that allow you to reason about client/server topologies with fine structure (and thereby avoiding the whole ORM situation, which attempts to magic over IO and of course fails)
for example, v3 is now rigorous enough in its transfer semantics that we turned on "throw exception on unserializable reference transfer" and none of our apps broke
cljs-libraries can declare, which npm packages they need. If shadow-cljs is started by cli, then these npm deps are installed automatically. However, this is not the case, if shadow-cljs is started via api as electric does it. In this case the command to install the packages has to be run manually (see https://clojurians.slack.com/archives/C6N245JGG/p1737884124914759 for reference). If we add that command to the starter template, then the user would not have to bother with that. dev.cljc needs two changes:
1. add this to :require ns form #?(:clj [shadow.cljs.devtools.server.npm-deps :as npm-deps])
2. add (npm-deps/main nil nil) before (shadow-server/start!)
(npm-deps/main nil nil)
(shadow-server/start!) ; no-op in calva shadow-cljs configuration which starts this out of band
(shadow/watch :dev) @dustingetz Is it ok, if I create a PR for the electric-starter-app?
Hi, just read the link. Are you sure this is a good idea?
Re the electric3-starter-app, it currently does not have any NPM deps, and we generally prefer to keep it as simple as possible because users already complain that it contains too much code
it would mimic the default behaviour of shadow-cljs cli tool. However, I understand that you want to keep the repo as lean as possible.
Maybe what we should try is - we will add these two lines and comment them out, and internally we can try running with these lines on for a bit and see if there are any issues
a couple other things we have to avoid: β’ users see package.json and think electric has js dependencies, which it does not β’ users see react.js in packjage.json (for like, an integration demo) and assume we depend on react.js - yes, we really do get this question, people don't read stuff β’ increasing our support surface area when it doesn't work - users start using us as front line support for their clojurescript problems, which causes all sorts of social problems
β’ users thinking electric is slow because they had to wait for npm
These are valid reasons. I guess that it is best to not include the npm lines to not confuse users. Iβll update my libs readme and document the diverging shadow-cljs behaviour there.
hmm, i dont understand what you need to document, given that electric3 doesn't have a package.json
does your library include the package.json?
I must be missing something
in my mind i imagine your library having a demo repo, and that demo repo includes a deps.edn and a package.json and a readme. Your repo can also provide the custom shadow configuration
does your library include the package.json?
it has a dependency on three.js. There is no tooling that recognizes a package.json in the lib.jar. Instead a cljs-library can declare its dependencies in a deps.cljs file located at the jar root. Shadow-cljs understands this file and will npm install the dependencies. A library consumer just needs to add the lib in the deps.edn file and shadow-cljs will handle the rest.
in my mind i imagine your library having a demo repo, and that demo repo includes a deps.edn and a package.json and a readme. Your repo can also provide the custom shadow configuration
That is a good idea. Is the electric-starter-app setup stable enough, so that I can provide my own demo based on the starter app?oh, shadow has implemented transitive deps across clojure jar files
Yes, you can fork electric*3*-starter-app, we rarely change it, i recommend adding it as an upstream git remote so you can see changes
There it is π https://github.com/HendrikLevering/electric3-threejs-demo