.. _gettingStartedLatchingDoc: .. index:: single: Example; Latching a Switch ================= Latching a Switch ================= **Reaction: Latch** :: reaction Latch { output: Switch onExecution: Reset terminateWhen: Done internalBlock: [ switch Switch { default: off reset: none }, switch Done { default: off reset: Reset }, trigger Reset {} ] streams: [ Switch >> Select ( whenOn: off whenOff: on ) >> Switch; on >> Done; ] } ---- **Rising Edges** .. highlight:: rst :: x x | x x x | Button x x | x x x | x x x x x x x | Latched x x | x x x x x .. highlight:: stride :: switch Button {} switch Latched {} Button >> Latch () >> Latched; ---- **Different Edges** .. highlight:: rst :: x x | x x x | Button x x | x x x | x x x x x x x x x x | Latched x x | x x .. highlight:: stride :: switch Button {} switch Latched {} Button >> OnEdge ( edge: [ 'Rising', 'Falling' ] ) >> Latch () >> Or () >> Latched;