Delay a task execution The task is getting info about a dom element
Created
February 18, 2021 17:31
-
-
Save PascalLeMerrer/8c44471b5e6c90cafdcef2d0032868bc to your computer and use it in GitHub Desktop.
Wait for launching a task & get DOM element dimensions
This file contains hidden or 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
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