Repository F# setup
open System
open System.IO
open System.Threading
open System.Threading.Tasks
open Axial
open Axial.Layers
open Axial.Console
open Axial.FileSystem
open Axial.Hosting
open Axial.Hosting.Browser
open Axial.Hosting.Node
open Axial.PlatformService
open Axial.State
open Axial.Telemetry
open Axial.Telemetry.JavaScript

Your First Application

Use App.run when a Flow is the root of an application. It carries cancellation from the calling Async and returns after the root scope and its resources have closed.

Show page setup
// Setup for the checked example on this page.
open Axial
/// Fails the docs test when an example's result differs from the value shown.
let shouldEqual expected actual =
    if actual <> expected then failwithf "Expected %A but got %A" expected actual
Verified
open Axial

let application : Flow<string> =
    flow {
        return "Hello from Flow"
    }

let run () =
    async {
        let! exit = App.run () application

        match exit with
        | Exit.Success message -> printfn "%s" message
        | Exit.Failure cause -> printfn "%s" (Cause.prettyPrint string cause)
    }
Requires & types
Requires: open Axial (packages: Axial)
val application: Flow<string>
val run: unit -> Async<unit>
Verified
App.run () application |> Async.RunSynchronously |> shouldEqual (Exit.Success "Hello from Flow" : Exit<string, Never>)
Requires & types
Requires: open Axial (packages: Axial)

run is the entry point: call run () |> Async.RunSynchronously from a [<EntryPoint>], or hand the same Async to an ASP.NET Core or Node host. The () value is the environment because this workflow has no dependencies. An application with an AppEnv record passes its live value in the same position.

Use App.start when a signal handler, desktop window, UI component, or external host will request shutdown later.

The Application Lifecycle guide covers start and stop ownership. Hosting guides show the .NET, Node, and browser boundaries.