Last active
January 28, 2019 15:17
-
-
Save JBetz/c5e677e5676246d61d503ea025952b12 to your computer and use it in GitHub Desktop.
dynamic that only updates when constructor changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
renderEither :: Dynamic t (Either a b) -> m () | |
renderEither eitherD = do | |
uniqEitherD <- holdUniqDynBy (\x y -> isRight x && isRight y || isLeft x && isLeft y) eitherD | |
dyn_ $ ffor uniqEitherD $ \case | |
Left val -> renderLeft $ fromLeft val <$> eitherD | |
Right val -> renderRight $ fromRight val <$> eitherD | |
renderLeft :: Dynamic t a -> m () | |
renderRight :: Dynamic t b -> m () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment