TheSharperDev

Educating about C# and F#

Set Timeout Function - Fable/F#

Fable brings F# to the browser. Here is how to call the setTimeout function from F#.

Set Timeout

setTimeout lives under the Fable.Core.JS module, so you’ll have to open that.

open Fable.Core.JS

window.onload <- fun _ ->

    //one liner
    setTimeout (fun () -> console.log("hello from the past!!!")) 4000 |> ignore

    //broken out to demonstate each part
    setTimeout 
        (fun () -> console.log("hello from the past!!!"))
        4000 
        |> ignore

Happy coding!!!!