- 60 LOC: demo_chat_exdended.cljc
Easy:
- make an ordinary Clojure function
query-pokemon-listfor the query - The query is blocking, and Electric Clojure is async, so use
e/offloadto move it to a thread pool.- (Don't block the event loop!)
e/offloadthrowsPendinguntil the query finishes, and then the exception "goes away"
- Client API, tested on Datomic Cloud
- database entity browser
- server paginated infinite scroll
- streaming information model - displays incremental resultsets as they become available (useful for slow queries)
- automatic backpressure and cancellation of abandoned queries
- custom web renderers with dynamic queries
Code is not optimized yet – we are still learning the idioms.
We use #user/uri rather than unquaified #uri per Alex Miller comment in the Ask Clojure thread.
License: public domain
| (defmacro future | |
| "Takes a body of expressions and yields a future object that will | |
| invoke the body in another thread, and will cache the result and | |
| return it on all subsequent calls to deref/@. If the computation has | |
| not yet finished, calls to deref/@ will block, unless the variant of | |
| deref with timeout is used. See also - realized?." | |
| {:added "1.1"} | |
| [& body] `(future-call (^{:once true} fn* [] ~@body))) | |
| | |
| (defn future-call |
Photon is a network-transparent Clojure/Script dialect for full-stack web application development. It uses macros to let you interweave client and server code in a single .CLJC file, so you can define a full-stack frontend/backend webapp all in one place. Photon is designed for stateful full-stack web applications with complex frontend/backend data sync requirements.
Newest demos:
- Datomic web explorer (Oct 2022)
Personal favorites:
This fullstack web app is 239 LOC in a single file, coded with just fns in the straightforward/easy style of PHP. All client/server I/O is managed!
It took him 10 hours. Thank you Malte! #Clojure
20220529.Photon.Datomic.Viewer.-.Malte.Nottmeyer.mp4
- 80 LOC: demo-reagent-interop.cljc (25 LOC for adapter)
20220729.photon.reagent.react.interop.mp4
Electric Clojure lets you code frontend/backend expressions that compose across the client/server boundary, due to compiler-managed network powered by DAGs. #Clojure
20230131.hello.photon.tranasfer.2.edited.mp4
p/defndefines a function that follows all the same laws as regular Clojure functions, but it’s actually a macro that compiles the function body into a DAG (Directed Acyclic Graph).