]> gitweb.factorcode.org Git - factor.git/commitdiff
frp: switcher ignores f values
authorSam Anklesaria <sam@Tintin.local>
Sun, 3 May 2009 17:14:17 +0000 (12:14 -0500)
committerSam Anklesaria <sam@Tintin.local>
Sun, 3 May 2009 17:14:17 +0000 (12:14 -0500)
extra/ui/frp/frp-docs.factor
extra/ui/frp/frp.factor

index af44567e4621720ea3f8ea401a19b51c1384e962..479a56e513af0b3eac934d859fc71b572951bce2 100644 (file)
@@ -36,7 +36,7 @@ HELP: <fold>
 { $values { "oldval" "starting value" } { "quot" "applied to update and previous values" } { "model" model } { "model'" model } }
 { $description "Similar to " { $link reduce } " but works on models, applying a quotation to the previous and new values at each update" } ;
 
-HELP: switch
+HELP: <switch>
 { $values { "signal1" model } { "signal2" model } { "signal'" model } }
 { $description "Creates a model that starts with the behavior of model1 and switches to the behavior of model2 on its update" } ;
 
index f972a3f80500eff6e86b982a12290c1be119308b..6b146c8296b76be9261940f215c1889c223beed4 100644 (file)
@@ -20,6 +20,8 @@ M: frp-table row-color color-quot>> [ call( a -- b ) ]  [ drop f ] if* ;
     focus-border-color >>focus-border-color
     transparent >>column-line-color ;
 : <frp-list> ( model -- table ) <frp-table> [ 1array ] >>quot ;
+: <frp-list*> ( -- table ) f <model> <frp-list> ;
+
 : <frp-field> ( -- field ) f <model> <model-field> ;
 
 ! Layout utilities
@@ -72,10 +74,10 @@ M: fold-model model-changed [ [ value>> ] [ [ oldval>> ] [ quot>> ] bi ] bi*
 
 TUPLE: switch-model < multi-model original switcher on ;
 M: switch-model model-changed 2dup switcher>> =
-   [ [ value>> ] [ t >>on ] bi* set-model ]
+   [ over value>> [ [ value>> ] [ t >>on ] bi* set-model ] [ 2drop ] if ]
    [ dup on>> [ 2drop ] [ [ value>> ] dip set-model ] if ] if ;
 M: switch-model model-activated [ original>> ] keep model-changed ;
-: switch ( signal1 signal2 -- signal' ) [ 2array switch-model <multi-model> ] 2keep
+: <switch> ( signal1 signal2 -- signal' ) [ 2array switch-model <multi-model> ] 2keep
    [ >>original ] [ >>switcher ] bi* ;
 
 TUPLE: mapped < model model quot ;