- 80 LOC: demo-reagent-interop.cljc (25 LOC for adapter)
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/defn
defines 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).
This video demonstrates traversing a filesystem tree from the frontend. The filesystem tree exists only on the server, and the HTML view exists only on the client. Nonetheless, we are able to unify the query/view logic into a single recursion in the simple, direct style of PHP, despite network. The Electric compiler automatically coordinates fine-grained reactive network sync.
Code note: in this video from last year, ~@
is the legacy syntax for client/server transfer, it has since been superseded by e/client
and e/server
markers.
20220621.photon.treeview.with.managed.nework.mp4
- No API, no client side database, no frontend state at all (except DOM)
- Literally all accidental complexity GONE
- Direct filesystem reads from the view
- Direct function composition in the style of PHP, despite network
- No API, no client side database, no frontend state at all (except DOM), no frontend/backend.
- Literally all accidental complexity GONE
- 100% of server data sync is managed by Electric
- Rows have arbitrary server local data access, here querying file metadata #clojure
- Optimized and no scroll jank – DOM elements are fixed in place and reused
- This demo uses DataScript's API for speculative transactions, not sure if can be done with sql read transactions.
- DataScript is on the server; code is network-transparent.
- 100 LOC for everything (table, query, popover, css, page)
20220910.branched.popover.staging.area.2.mp4
- 100% of server data sync is managed by Photon
- Rows have arbitrary server local data access, here querying file metadata #clojure
20220906.infinite.scroll.node.modules.mp4
Below is the approximate code (I've removed all the table/file stuff to just see the essential scroll logic)
(ns user.datafy-fs | |
"nav implementation for java file system traversals" | |
(:require [clojure.core.protocols :as ccp :refer [nav]] | |
[clojure.datafy :refer [datafy]] | |
[clojure.spec.alpha :as s] | |
[hyperfiddle.rcf :refer [tests]]) | |
(:import [java.nio.file Path Paths Files] | |
java.io.File | |
java.nio.file.LinkOption | |
[java.nio.file.attribute BasicFileAttributes FileTime])) |
- An early demonstration "Compiler Managed Network" and the extreme dynamic composition it makes possible
- TodoMVC Composed merely calls the previous TodoMVC function inside a for loop.