]> gitweb.factorcode.org Git - factor.git/commitdiff
switch models revert on false value
authorSam Anklesaria <sam@Tintin.local>
Mon, 1 Jun 2009 02:49:55 +0000 (21:49 -0500)
committerSam Anklesaria <sam@Tintin.local>
Mon, 1 Jun 2009 02:49:55 +0000 (21:49 -0500)
extra/ui/frp/signals/signals.factor

index 145c25c0d6200881309cce2f88a3d094d0fbd6cf..04364536e693a83a31a0fc7d5d1b81f6bd1a13a4 100644 (file)
@@ -32,9 +32,9 @@ M: updater-model (model-changed) tuck updates>> =
    [ >>values ] [ >>updates ] bi* ;
 
 TUPLE: switch-model < multi-model original switcher on ;
-M: switch-model (model-changed) 2dup switcher>> =
-   [ [ value>> ] [ t >>on ] bi* set-model ]
-   [ dup on>> [ 2drop ] [ [ value>> ] dip set-model ] if ] if ;
+M: switch-model model-changed 2dup switcher>> =
+   [ [ value>> ] dip over [ t >>on set-model ] [ nip f swap (>>on) ] if ]
+   [ dup on>> [ 2drop ] [ [ value>> ] dip over [ set-model ] [ 2drop ] if ] if ] if ;
 : <switch> ( signal1 signal2 -- signal' ) swap [ 2array switch-model <multi-model> ] 2keep
    [ >>original ] [ >>switcher ] bi* ;
 M: switch-model model-activated [ original>> ] keep model-changed ;