Web applications without callbacks or side-effects. Reflex-DOM brings the power of functional reactive programming (FRP) to the web. Build HTML and other Document Object Model (DOM) data with a pure functional interface.
Hi. I've found this function quite useful. The naming reflects its similarity to monadic bind but I'm open to suggestions for alternative names:
bindEvent :: (MonadFix m, Adjustable t m, MonadHold t m)
=> m (Event t a) -> (a -> m (Event t b)) -> m (Event t b)
bindEvent first secondFun = do
rec
let becomeSecondEv = fmap secondFun firstEv
(firstEv, secondEvEv) <- runWithReplace first becomeSecondEv
switchEvent secondEvEv
where switchEvent is from https://github.com/reflex-frp/reflex/issues/49:
switchEvent :: (Reflex t, MonadHold t m) => Event t (Event t a) -> m (Event t a)
switchEvent = fmap switch . hold never
I've used it for creating login widgets that behave similarly to Google's (username and password entry are two separate widgets where the second's creation is triggered by the first).
The type is convenient for creating long chains of widgets that dynamically update while carrying along the payload from previous widgets' events.
Hi. I've found this function quite useful. The naming reflects its similarity to monadic bind but I'm open to suggestions for alternative names:
bindEvent :: (MonadFix m, Adjustable t m, MonadHold t m) => m (Event t a) -> (a -> m (Event t b)) -> m (Event t b) bindEvent first secondFun = do rec let becomeSecondEv = fmap secondFun firstEv (firstEv, secondEvEv) <- runWithReplace first becomeSecondEv switchEvent secondEvEv
where switchEvent is from https://github.com/reflex-frp/reflex/issues/49: switchEvent :: (Reflex t, MonadHold t m) => Event t (Event t a) -> m (Event t a) switchEvent = fmap switch . hold never
I've used it for creating login widgets that behave similarly to Google's (username and password entry are two separate widgets where the second's creation is triggered by the first).
The type is convenient for creating long chains of widgets that dynamically update while carrying along the payload from previous widgets' events.