Macro for creating a plain app
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
assets
src/tiny_app
.gitattributes
.gitignore
README.md
meyvn.edn
package.json
shadow-cljs.edn
yarn.lock

README.md

Tiny App for Repso

Try how tiny it could be with help of macros. Project is experimental, don't use in real-world projects.

Clojars Project

[respo/tiny-app "0.3.0"]

Example

(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})

(def main! (:init! app))
(def reload! (:reload! app))

More explanations for options:

  • store: pure data
  • updater: pure function
  • view: pure function
  • mount-target: DOM node for mounting app
  • show-ops?: if true, calling dispatch! prints logs

Require code from namespaces:

(ns tiny-app.example
  (:require [respo.core :refer [defcomp <> div button span]]
            [tiny-app.core :refer [create-app->]]))

Develop

yarn
yarn try
# open localhost:8080

License

MIT