Skip to content

datafy-id/electric_hello

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Electric Clojure

This is my second attempt to figure out the inner workings of Electric Clojure in hopes of making full use of it as intended.

The Gist

Basically, we can think of it as a clojure dialect that allows us to create full stack web applications (i.e. client and server) declaratively with a simple clojure-like DSL.

Its purpose is similar to the recently released reactjs feature: React Server Component (RSC). This feature allows developers to use the same syntax (JSX), to create application that can be arbitrarily composed from components that could be run on the server and or on the client as a single unit of declaration.

An Electric Clojure component looks like the one below. This shows the composition of units that are running on the server and on the client, interleaved arbitrarily.

(e/defn App []
  (e/client
    (let [client-time (e/client (e/system-time-ms))
          server-time (e/server (e/system-time-ms))]
      (dom/div
        (dom/div (dom/text "client-time: " client-time))
        (dom/div (dom/text "server-time: " server-time))
        (dom/div (dom/text "millis difference: " (- server-time client-time)))))))

The Electric compiler will compile this component into server and client artifacts, and the runtime will orchestrate the overlapping execution and delivery of necessary data between the client and server at the appropriate time.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published