freactive - 声明式 DOM 库


EPL
跨平台

软件简介

freactive 是一个高性能、纯 Clojurescript
实现的声明式 DOM 库。使用 hiccup 风格的语法和 Clojure
内建的 deref 和 atom 模式。灵感来自于 reagent, om
reflex

示例代码:

(ns example1
(:refer-clojure :exclude [atom])
(:require [freactive.core :refer [atom cursor]]
[freactive.dom :as dom])
(:require-macros [freactive.macros :refer [rx]]))

(defonce mouse-pos (atom nil))

(defn view []
[:div
{:width “100%” :height “100%” :style {:border “1px solid black”}
:on-mousemove (fn [e] (reset! mouse-pos [(.-clientX e) (.-clientY e)]))}
[:h1 “Hello World!”]
[:p “Your mouse is at: ” (rx (str @mouse-pos))]])

(defonce root (dom/append-child! (.-body js/document) [:div#root]))

(dom/mount! root (view))