Skip to content

Latest commit

 

History

History
41 lines (25 loc) · 1.05 KB

03-flows.md

File metadata and controls

41 lines (25 loc) · 1.05 KB

Flows

Status: (alpha)

Flows provide a newer mechanism for derived state, by storing the derived result of some calculation in the app-db at the location you specify.

Flows also manage their own life-cycle ensuring it cleans up after itself when the Flow is no longer needed.

For detailed information see re-frame's Flow documentation.

Getting started

Register the built-in Flow life-cycle effects in your app's main function:

(require '[hti.re-dash.alpha :as rd]')  ;; <== Flows are available in the alpha namespace

(rd/register-defaults!)

Register a Flow

(def area-flow
  {:id          :garage-area
   :inputs      {:w [:garage :width]
                 :h [:garage :length]}
   :output      (fn calc-area
                  [{:keys [w h]}]
                  (* w h))
   :path        [:garage :area]})


(rd/reg-flow area-flow)

Sample app

samples/flow Shows an example of using Flows to calculate a derived result of some calculation, in addition to Flow life-cycle controls.