Created
December 10, 2014 17:32
-
-
Save micha/998911896dbd457040c1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| (page "index.html" | |
| (:require | |
| [tailrecursion.hoplon.reload :refer [reload-all]])) | |
| (reload-all 1000) | |
| (defn clamp [lower x upper] | |
| (max lower (min x upper))) | |
| ;; this cell contains some info, but we want to make sure | |
| ;; it satisfies some constraint (eg. clamped to some range) | |
| (defc age 0) | |
| ;; use javelin "lens" to clamp age to range [0, 100] | |
| (defc= clamped-age age #(reset! age (clamp 0 % 100))) | |
| (html | |
| (head) | |
| (body | |
| (h1 "Hello, World!") | |
| (form | |
| (input | |
| :type "text" | |
| :value clamped-age | |
| :change #(reset! clamped-age (js/parseInt @%)))))) | |
| ;; debug cell value to js console | |
| (cell= (prn :clamped-age clamped-age)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment