Jesuspc
Jesuspc

Reputation: 1734

Conditionally adding DOM elements with Reflex

I have a function that receives a Dynamic and has to display a dom element which will contain a different kind of child depending on the value in the Dynamic. Is there a way to do such thing using Reflex and Reflex-Dom? The code would look like this if the value in the dynamic could be unwrapped by pattern matching:

myNode :: MonadWidget t m => Dynamic t Bool -> m (Event t ())
myNode (Dynamic True) = elClass "div" "foo" $
  elClass "div" "bar"
myNode (Dynamic False) = blank

Upvotes: 1

Views: 236

Answers (1)

Jesuspc
Jesuspc

Reputation: 1734

I've found the solution. The function dyn can be used in those situations. Also see this other stackoverflow question.

Upvotes: 1

Related Questions