- 60 LOC: demo_chat_exdended.cljc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; ## General helpers | |
(ns app.helpers.rama | |
(:require | |
[missionary.core :as m] | |
[taoensso.timbre :as timbre]) | |
(:import | |
[com.rpl.rama Depot PState Path ProxyState$Callback RamaModule] | |
[com.rpl.rama.test InProcessCluster LaunchConfig] | |
[hyperfiddle.electric Failure Pending])) |
Easy:
- make an ordinary Clojure function
query-pokemon-list
for the query - The query is blocking, and Electric Clojure is async, so use
e/offload
to move it to a thread pool.- (Don't block the event loop!)
e/offload
throwsPending
until the query finishes, and then the exception "goes away"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns app.mappy | |
#?(:cljs (:require-macros app.mappy)) | |
(:require #?(:clj [datascript.core :as d]) ; database on server | |
#?(:clj [clojure.data.csv :as csv]) | |
[hyperfiddle.electric :as e] | |
[hyperfiddle.electric-dom2 :as dom] | |
[hyperfiddle.electric-ui4 :as ui] | |
#?(:cljs ["@openlayers-elements/core/ol-map" :as ol-map]) | |
#?(:cljs ["@openlayers-elements/maps/ol-layer-openstreetmap" :as ol-layer-openstreetmap]) | |
#?(:cljs ["@openlayers-elements/core/ol-layer-vector" :as ol-layer-vector]) |
- 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.
- 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
- 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.
20220822.Todomvc.Composed.mp4
- it's multiplayer! 0 LOC cost
- state is durable! (server side database) 0 LOC cost
- See those pending spinners? We've added a server delay to demonstrate managed load states.
20220817.todomvc.mp4
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
osacompile -x -o test.app<<EOF | |
set progress description to "Download progress indicator" | |
set progress additional description to "Preparing…" | |
set progress total steps to -1 | |
delay 5 | |
set i to 0 | |
set progress total steps to 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bb | |
#_" -*- mode: clojure; -*-" | |
;; Based on https://github.com/babashka/babashka/blob/master/examples/image_viewer.clj | |
(ns http-server | |
(:require [babashka.fs :as fs] | |
[clojure.java.browse :as browse] | |
[clojure.string :as str] | |
[clojure.tools.cli :refer [parse-opts]] | |
[org.httpkit.server :as server] |
NewerOlder