Tiny App for Repso
Try how tiny it could be with help of macros. Project is experimental, don't use in real-world projects.
[respo/tiny-app "0.3.0"]
(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 dataupdater
: pure functionview
: pure functionmount-target
: DOM node for mounting appshow-ops?
: iftrue
, callingdispatch!
prints logs
Require code from namespaces:
(ns tiny-app.example
(:require [respo.core :refer [defcomp <> div button span]]
[tiny-app.core :refer [create-app->]]))
yarn
yarn try
# open localhost:8080
MIT