Skip to content

Instantly share code, notes, and snippets.

@PascalLeMerrer
Created February 18, 2021 17:31
Show Gist options
  • Save PascalLeMerrer/8c44471b5e6c90cafdcef2d0032868bc to your computer and use it in GitHub Desktop.
Save PascalLeMerrer/8c44471b5e6c90cafdcef2d0032868bc to your computer and use it in GitHub Desktop.
Wait for launching a task & get DOM element dimensions

Delay a task execution The task is getting info about a dom element

type Msg
= GotContainerInfo (Result Dom.Error Dom.Element)
init =
(initialModel,
Process.sleep 1000
|> Task.andThen (\_ -> Dom.getElement "container")
|> Task.attempt GotContainerInfo
)
update msg model =
case msg of
GotContainerInfo (Ok info) ->
let
Debug.log "Info" info
in
( model, Cmd.none )
GotContainerInfo (Err error) ->
let
Debug.log "Error" error
in
( model, Cmd.none )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment