on develop help sign in
Add 'gate'
commit0b96365bd5839b938596c111f661c6a2b153f58c authorRyan Trinkle <ryan.trinkle@gmail.com> dateSat 28 Feb 2015, 19:45 (12 years ago) parentf45b0ab
1 file changed+3
src/Reflex/Class.hs+3
src/Reflex/Class.hs+3
@@ -227,3 +227,6 @@ switchPromptly ea0 eea = do
227227instance Reflex t => Align (Event t) where
228228 nil = never
229229 align ea eb = fmapMaybe dmapToThese $ merge $ DMap.fromList [WrapArg LeftTag :=> ea, WrapArg RightTag :=> eb]
230+
231+gate :: Reflex t => Behavior t Bool -> Event t a -> Event t a
232+gate = attachWithMaybe $ \allow a -> if allow then Just a else Nothing