Init

This module defines the app initialization task. This is a special kind of task that can only be passed as the result of an application initialization. You'll typically use this module in order to initialize sub-systems like FileSystem or ChildProcess.

type alias Task a = Task a

This is like a Task, but can only be run as part of initializing your program. This is usually used for values which should be provided to your program, and only your program, as opposed to third-party packages.

await : Task a -> (a -> Task b) -> Task b

This let's you wait for the completion of an Task before either starting your application, or begin initialization of another Task.

Init.await Terminal.initialize <| \termConfig ->
Init.await FileSystem.initialize <| \fileSystemConfig ->
    -- Start your own program with the values from Terminal and FileSystem
    Program.startProgram
        { model = 1
        , commands = Cmd.none
        }
awaitTask : Task Never a -> (a -> Task b) -> Task b

This let's you wait for the completion of a Task before either starting your application, or begin initialization of another Task.

Init.await Terminal.initialize <| \termConfig ->
Init.awaitTask Task.now <| \time ->
    -- Start your own program with the values from Terminal and FileSystem
    Program.startProgram
        { model = time
        , commands = Cmd.none
        }