Don't use a halogen component if the html element is missing

I am completely new to purescript and halogen. I am trying to display a halogen component (myButton) when an html element exists and do nothing.

displayButton :: Eff (HA.HalogenEffects ()) Unit
displayButton = HA.runHalogenAff do
  containerElement <- HA.selectElement (QuerySelector "#halogen-button")
  case containerElement of
    Nothing -> ???
    Just element -> runUI myButton unit element

      

I don't know what code to put in the Nothing clause so that my code type checks and does nothing in this case.

+3


source to share


1 answer


pure unit

is the "do nothing" you could add. You can also use for_

to make it a little better

for_ containerElement \element ->
  runUI myButton unit element

      



What if you are taking into account the same as:

for_ containerElement (runUI myButton unit)

      

+1


source







All Articles