Skip to content

Loading continues even after loading screen disappears #255

Closed
@mikesol

Description

@mikesol

I'm using trypurescript to prototype some Halogen apps, and there is an interesting phenomenon where the loading screen disappears about 1-2 seconds before the Halogen app appears. Here is my app:

module Main where

import Prelude

import Effect (Effect)
import Halogen.Aff as HA
import Halogen.VDom.Driver (runUI)
import Prelude
import Halogen as H
import Halogen.HTML as HH
import Halogen.HTML.Events as HE

type State
  = { count :: Int }

data Action
  = Increment

component :: forall q i o m. H.Component q i o m
component =
  H.mkComponent
    { initialState: \_ -> { count: 0 }
    , render
    , eval: H.mkEval H.defaultEval { handleAction = handleAction }
    }

render :: forall cs m. State -> H.ComponentHTML Action cs m
render state =
  HH.div_
    [ HH.p_
        [ HH.text $ "You clicked " <> show state.count <> " times" ]
    , HH.button
        [ HE.onClick \_ -> Increment ]
        [ HH.text "Click me" ]
    ]

handleAction :: forall cs o m. Action  H.HalogenM State Action cs o m Unit
handleAction = case _ of
  Increment -> H.modify_ \st -> st { count = st.count + 1 }

main :: Effect Unit
main = HA.runHalogenAff do
  body <- HA.awaitBody
  runUI component unit body

If you copy the code above into trypurescript, you'll see that after the load screen disappears, there's a 1-2 second delay before the button appears.

I can try to put together a PR to keep the loading screen up for longer, but first it'd be good to confirm that this is actually the case for other folks as well. My initial guess is that this line setting up the iframe would require some sort of callback hook from the frame that the initial JS rendering is done before making the loading screen disappear. Thanks in advance for your ideas/help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions