- forms, tables, hyperlinks, routing
- queries on backend, rendering on frontend
- dynamic query dependencies
- WYSIWYG in-browser live editor
Strong composition – it's a functional expression! Compiler-managed network
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.
Below is the approximate code (I've removed all the table/file stuff to just see the essential scroll logic)
| (ns dustingetz.datafy-fs | |
| "nav implementation for java file system traversals" | |
| (:require [clojure.core.protocols :as ccp :refer [nav]] | |
| [clojure.datafy :refer [datafy]] ; tests only | |
| [clojure.spec.alpha :as s] | |
| [contrib.assert :refer [check]] | |
| [dustingetz.datafy-fs :as fs] | |
| [hyperfiddle.rcf :refer [tests]] | |
| [clojure.java.io :as io]) | |
| (:import [java.nio.file Path Paths Files] |
Electric is a "multi tier" 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. Electric is designed for rich dynamic applications with reactive user interfaces and complex frontend/backend data sync requirements.
| (ns user.demo-5-todomvc | |
| "Requires -Xss2m to compile. default 1m JVM ThreadStackSize is exceeded by photon compiler due to large macroexpansion | |
| resulting in false StackOverflowError during analysis." | |
| (:require #?(:clj [datascript.core :as d]) | |
| [hyperfiddle.photon :as p] | |
| [hyperfiddle.photon-ui :as ui] | |
| [hyperfiddle.photon-dom :as dom]) | |
| #?(:cljs (:require-macros user.demo-5-todomvc))) | |
| (defonce !conn #?(:clj (d/create-conn {}) :cljs nil)) ; server |