on develop help sign in
Add 'gate'
0b96365Ryan Trinkle
src/Reflex/Class.hs+3
@@ -227,3 +227,6 @@ switchPromptly ea0 eea = do
227instance Reflex t => Align (Event t) where
227instance Reflex t => Align (Event t) where
228 nil = never
228 nil = never
229 align ea eb = fmapMaybe dmapToThese $ merge $ DMap.fromList [WrapArg LeftTag :=> ea, WrapArg RightTag :=> eb]
229 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