module Miso.Delegate where
import Control.Monad.IO.Class
import Data.IORef
import qualified Data.Map as M
import GHCJS.Marshal
import GHCJS.Types (JSVal)
import qualified JavaScript.Object.Internal as OI
import Miso.FFI
import Miso.Html.Types
import Miso.String
delegator
:: JSVal
-> IORef VTree
-> M.Map MisoString Bool
-> JSM ()
delegator mountPointElement vtreeRef es = do
evts <- toJSVal (M.toList es)
delegateEvent mountPointElement evts $ do
VTree (OI.Object val) <- liftIO (readIORef vtreeRef)
pure val