Try how tiny it could be with help of macros. Project is experimental, don't use in real-world projects.
[respo/tiny-app "0.2.3"]
(def store
; retusn a Map with data and states: {:states {}}
)
(defn updater [store op op-data]
; op is a keyword, op-data is an arbitrary value
; retuns a new store
)
(defcomp comp-container [store]
; returns virtual DOM like: (div {})
)
(def app
(create-app-> {:model store
:updater updater
:view comp-container
:mount-target (.querySelector js/document ".app")
:show-ops? true})
(set! (.-onload js/window) (:start-app! app))
(def reload! (:reload! app))
More explanations for options:
store
: pure dataupdater
: pure functionview
: pure functionmount-target
: DOM node for mounting appshow-ops?
: if true
, calling dispatch!
prints logsRequire code from namespaces:
(ns tiny-app.example
(:require [respo.macros :refer [defcomp <> div button span]]
[tiny-app.core :refer [create-app->]]))
yarn
yarn try
# open localhost:8080
MIT
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close