UIx + re-frame

UIx

Shipclojure uses UIx as a react wrapper as it supports more modern react better than consacrated tools like Reagent.

See UIx docs for more details.

re-frame

While re-frame was developed specifically for Reagent, it can very well be used with other wrappers like Helix and UIx.

  1. Instead of using the clasic subscription as you would in Reagent:

(let [value @(rf/subscribe [:my-value])])

There is a hook to subscribe to the re-frame db that can be used from UIx components.

(ns saas.page
    (:require
        [uix.core :refer [defui $]]
        [re-frame.core :as rf]
        [uix.re-frame :refer [use-subscribe]]))

(defui my-component
    [props]
  (let [value (use-subscribe [:my-value])] ;; reactive subscription from store
    ($ :button {:on-click #(rf/dispatch [:increment-value])} ;dispatching works the same
        (str "The value is " value))))

Last updated