Last active
March 20, 2018 05:50
-
-
Save mightybyte/a81ff034ae6ca2a4d45d to your computer and use it in GitHub Desktop.
Attaching reflex to a particular node
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
{-# LANGUAGE ConstraintKinds #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE RecursiveDo #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE TypeFamilies #-} | |
------------------------------------------------------------------------------ | |
import Control.Concurrent | |
import Control.Monad | |
import Control.Monad.Trans | |
import Control.Monad.Trans.Reader | |
import GHCJS.DOM | |
import GHCJS.DOM.Document | |
import GHCJS.DOM.Element | |
import GHCJS.DOM.EventM (preventDefault, eventTarget) | |
import GHCJS.DOM.HTMLDocument | |
import GHCJS.DOM.Types hiding (Event, Text) | |
import Reflex.Dom hiding (getKeyEvent) | |
------------------------------------------------------------------------------ | |
------------------------------------------------------------------------------ | |
waitUntilJust :: IO (Maybe a) -> IO a | |
waitUntilJust a = do | |
mx <- a | |
case mx of | |
Just x -> return x | |
Nothing -> do | |
threadDelay 10000 | |
waitUntilJust a | |
------------------------------------------------------------------------------ | |
main :: IO () | |
main = runWebGUI $ \webView -> do | |
doc <- waitUntilJust $ liftM (fmap castToHTMLDocument) $ | |
webViewGetDomDocument webView | |
root <- waitUntilJust $ liftM (fmap castToHTMLElement) $ | |
documentGetElementById doc "app-tag-id" | |
attachWidget root webView $ do | |
yourApp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Get the following traceback
Not exactly sure what to put after the do block. I tried "el "div" $ text "Welcome to Reflex"", which yielded similar complaints about webView.