3
3
__ ,
4
4
adjust ,
5
5
any ,
6
+ append ,
6
7
concat ,
7
8
contains ,
8
9
findIndex ,
@@ -43,7 +44,6 @@ export function hydrateInitialOutputs() {
43
44
}
44
45
}
45
46
46
-
47
47
function triggerDefaultState ( dispatch , getState ) {
48
48
const { graphs} = getState ( ) ;
49
49
const { InputGraph} = graphs ;
@@ -583,7 +583,49 @@ function updateOutput(
583
583
* Organize props by shared outputs so that we
584
584
* only make one request per output component
585
585
* (even if there are multiple inputs).
586
+ *
587
+ * For example, we might render 10 inputs that control
588
+ * a single output. If that is the case, we only want
589
+ * to make a single call, not 10 calls.
590
+ */
591
+
592
+ /*
593
+ * In some cases, the new item will be an output
594
+ * with its inputs already rendered (not rendered)
595
+ * as part of this update.
596
+ * For example, a tab with global controls that
597
+ * renders different content containers without any
598
+ * additional inputs.
599
+ *
600
+ * In that case, we'll call `updateOutput` with that output
601
+ * and just "pretend" that one if its inputs changed.
602
+ *
603
+ * If we ever add logic that informs the user on
604
+ * "which input changed", we'll have to account for this
605
+ * special case (no input changed?)
586
606
*/
607
+
608
+
609
+ const outputIds = [ ] ;
610
+ keys ( newProps ) . forEach ( idAndProp => {
611
+ if (
612
+ // It's an output
613
+ InputGraph . dependenciesOf ( idAndProp ) . length === 0 &&
614
+ /*
615
+ * And none of its inputs are generated in this
616
+ * request
617
+ */
618
+ intersection (
619
+ InputGraph . dependantsOf ( idAndProp ) ,
620
+ keys ( newProps )
621
+ ) . length == 0
622
+ ) {
623
+ outputIds . push ( idAndProp ) ;
624
+ delete newProps [ idAndProp ] ;
625
+ }
626
+ } ) ;
627
+
628
+ // Dispatch updates to inputs
587
629
const reducedNodeIds = reduceInputIds (
588
630
keys ( newProps ) , InputGraph ) ;
589
631
const depOrder = InputGraph . overallOrder ( ) ;
@@ -594,6 +636,28 @@ function updateOutput(
594
636
sortedNewProps . forEach ( function ( nodeId ) {
595
637
dispatch ( notifyObservers ( newProps [ nodeId ] ) ) ;
596
638
} ) ;
639
+
640
+ // Dispatch updates to lone outputs
641
+ outputIds . forEach ( idAndProp => {
642
+ const requestUid = uid ( ) ;
643
+ dispatch ( setRequestQueue (
644
+ append ( {
645
+ controllerId : null , // ??
646
+ status : 'loading' ,
647
+ uid : requestUid ,
648
+ requestTime : Date . now ( )
649
+ } , getState ( ) . requestQueue )
650
+ ) ) ;
651
+ updateOutput (
652
+ idAndProp . split ( '.' ) [ 0 ] ,
653
+ idAndProp . split ( '.' ) [ 1 ] ,
654
+ null ,
655
+ getState ,
656
+ requestUid ,
657
+ dispatch
658
+ ) ;
659
+ } )
660
+
597
661
}
598
662
599
663
0 commit comments