@@ -31,14 +31,16 @@ Here's a basic `flow`. It describes how to derive the area of a room from its di
3131{: id : room-area
3232 : inputs {: w [ : room : width ]
3333 : 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}]
3535 (* w h))
3636 : path [ : room : area ] }
3737</div >
3838
3939- ** ` :id ` ** - uniquely identifies this flow.
4040- ** ` :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.
4244- ** ` :path ` ** - denotes * where* the derived value should be stored.
4345
4446Every 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`:
9092 {: id : garage-area
9193 : inputs {: w [ : garage : width ]
9294 : 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))
9596 : path [ : garage : area ] })
9697
9798(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
252253{: id : main-room-ratio
253254 : inputs {: kitchen (rf/flow-input ::kitchen-area)
254255 : living-room (rf/flow-input ::living-room-area)}
255- : output (fn [ _ {: keys [ kitchen living-room] }]
256+ : output (fn [ {: keys [ kitchen living-room] }]
256257 (/ kitchen living-room))
257258 : path [ : ratios : main-rooms ] }
258259</div >
@@ -286,11 +287,10 @@ Here's another room area flow:
286287 {: id : kitchen-area
287288 : inputs {: w [ : kitchen : width ]
288289 : 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))
291291 : path [ : kitchen : area ]
292292 : live-inputs {: tab [ : tab ] }
293- : live ? (fn [ db {: keys [ tab] }]
293+ : live ? (fn [ {: keys [ tab] }]
294294 (= tab : kitchen ))})
295295</div >
296296
@@ -478,7 +478,7 @@ It builds a flow that validates our item list against the requirements:
478478 : path [ ::error-state]
479479 : inputs {: items [ ::items]
480480 : tab (rf/flow-input : current-tab )}
481- : output (fn [ _ {: keys [ items] }]
481+ : output (fn [ {: keys [ items] }]
482482 (let [ ct (count items)]
483483 (cond
484484 (> ct max-items) : too-many
@@ -738,14 +738,14 @@ Even though `::num-balloons-to-fill-kitchen` depends on other flows, we can acce
738738 {: id ::kitchen-volume
739739 : inputs {: area [ : kitchen : area ]
740740 : height [ : kitchen : height ] }
741- : output (fn [ _ {: keys [ area height] }]
741+ : output (fn [ {: keys [ area height] }]
742742 (* area height))
743743 : path [ : kitchen : volume ] })
744744
745745(rf/reg-flow
746746 {: id ::num-balloons-to-fill-kitchen
747747 : inputs {: volume ::kitchen-volume}
748- : output (fn [ _ {: keys [ volume] }]
748+ : output (fn [ {: keys [ volume] }]
749749 (let [ std-balloon-volume 2.5]
750750 (/ volume std-balloon-volume)))})
751751
0 commit comments