switch models revert on false value

db4
Sam Anklesaria 2009-05-31 21:49:55 -05:00
parent b705306558
commit 733dbe4585
1 changed files with 3 additions and 3 deletions
extra/ui/frp/signals

View 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 ;