Skip to content

Instantly share code, notes, and snippets.

@myguidingstar-zz
Created July 3, 2016 15:44
Show Gist options
  • Save myguidingstar-zz/bfd0d94f9b1541b944667b0f7cfc46f7 to your computer and use it in GitHub Desktop.
Save myguidingstar-zz/bfd0d94f9b1541b944667b0f7cfc46f7 to your computer and use it in GitHub Desktop.
Use Rum with Javeline
[hoplon/javelin "3.8.4"]
[rum "0.9.1"]
<!doctype html>
<html>
<head>
<title>Some app</title>
<meta charset="utf-8">
</head>
<body>
<div id="app"></div>
</body>
<script type="text/javascript" src="main.js"></script>
</html>
(ns some.app
(:require [rum.core :as rum]
[javelin.core :refer-macros [defc defc=]]))
(defc a 0)
(defc b 10)
(defc= c (* a b))
(rum/defc body < rum/reactive
[]
[:div
[:input {:type "range"
:min -5 :max 5
:on-change #(reset! a (.. % -target -value))
:value (rum/react a)}]
[:br]
[:input {:type "range"
:min -5 :max 5
:on-change #(reset! b (.. % -target -value))
:value (rum/react b)}]
[:p (str (rum/react a) " × " (rum/react b)
" = " (rum/react c))]])
(defn main []
(rum/mount (body) (.getElementById js/document "app")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment