@@ -31,14 +31,16 @@ Here's a basic `flow`. It describes how to derive the area of a room from its di
31
31
{: id : room-area
32
32
: inputs {: w [ : room : width ]
33
33
: h [ : room : length ] }
34
- : output (fn calc-area [ previous-area {: keys [ w h] : as inputs}]
34
+ : output (fn calc-area [ {: keys [ w h] : as inputs}]
35
35
(* w h))
36
36
: path [ : room : area ] }
37
37
</div >
38
38
39
39
- ** ` :id ` ** - uniquely identifies this flow.
40
40
- ** ` :inputs ` ** - a map of ` app-db ` paths to observe for changes.
41
- - ** ` :output ` ** - calculates the new derived value. Accepts the previous result, and a map of input values.
41
+ - ** ` :output ` ** - calculates the new derived value.
42
+ - Takes a map of resolved inputs.
43
+ - Simply takes ` app-db ` if there are no inputs.
42
44
- ** ` :path ` ** - denotes * where* the derived value should be stored.
43
45
44
46
Every event, when the values of ` :inputs ` change, ` :output ` is run, and the result is stored in ` app-db ` at ` :path ` .
@@ -90,8 +92,7 @@ Now the interesting part, we use `reg-flow`:
90
92
{: id : garage-area
91
93
: inputs {: w [ : garage : width ]
92
94
: h [ : garage : length ] }
93
- : output (fn area [ previous-area {: keys [ w h] : as inputs}]
94
- (* w h))
95
+ : output (fn [ {: keys [ w h] }] (* w h))
95
96
: path [ : garage : area ] })
96
97
97
98
(rf/reg-flow garage-area-flow)
@@ -252,7 +253,7 @@ Here's a flow using two other flows as inputs: `::kitchen-area` and `::living-ro
252
253
{: id : main-room-ratio
253
254
: inputs {: kitchen (rf/flow-input ::kitchen-area)
254
255
: living-room (rf/flow-input ::living-room-area)}
255
- : output (fn [ _ {: keys [ kitchen living-room] }]
256
+ : output (fn [ {: keys [ kitchen living-room] }]
256
257
(/ kitchen living-room))
257
258
: path [ : ratios : main-rooms ] }
258
259
</div >
@@ -286,11 +287,10 @@ Here's another room area flow:
286
287
{: id : kitchen-area
287
288
: inputs {: w [ : kitchen : width ]
288
289
: h [ : kitchen : length ] }
289
- : output (fn area [ previous-area {: keys [ w h] : as inputs}]
290
- (* w h))
290
+ : output (fn [ {: keys [ w h] }] (* w h))
291
291
: path [ : kitchen : area ]
292
292
: live-inputs {: tab [ : tab ] }
293
- : live ? (fn [ db {: keys [ tab] }]
293
+ : live ? (fn [ {: keys [ tab] }]
294
294
(= tab : kitchen ))})
295
295
</div >
296
296
@@ -478,7 +478,7 @@ It builds a flow that validates our item list against the requirements:
478
478
: path [ ::error-state]
479
479
: inputs {: items [ ::items]
480
480
: tab (rf/flow-input : current-tab )}
481
- : output (fn [ _ {: keys [ items] }]
481
+ : output (fn [ {: keys [ items] }]
482
482
(let [ ct (count items)]
483
483
(cond
484
484
(> ct max-items) : too-many
@@ -738,14 +738,14 @@ Even though `::num-balloons-to-fill-kitchen` depends on other flows, we can acce
738
738
{: id ::kitchen-volume
739
739
: inputs {: area [ : kitchen : area ]
740
740
: height [ : kitchen : height ] }
741
- : output (fn [ _ {: keys [ area height] }]
741
+ : output (fn [ {: keys [ area height] }]
742
742
(* area height))
743
743
: path [ : kitchen : volume ] })
744
744
745
745
(rf/reg-flow
746
746
{: id ::num-balloons-to-fill-kitchen
747
747
: inputs {: volume ::kitchen-volume}
748
- : output (fn [ _ {: keys [ volume] }]
748
+ : output (fn [ {: keys [ volume] }]
749
749
(let [ std-balloon-volume 2.5]
750
750
(/ volume std-balloon-volume)))})
751
751
0 commit comments