AVLoop 1.4.1

.NET 7.0
dotnet add package AVLoop --version 1.4.1
NuGet\Install-Package AVLoop -Version 1.4.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AVLoop" Version="1.4.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AVLoop --version 1.4.1
#r "nuget: AVLoop, 1.4.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install AVLoop as a Cake Addin
#addin nuget:?package=AVLoop&version=1.4.1

// Install AVLoop as a Cake Tool
#tool nuget:?package=AVLoop&version=1.4.1


A little bit of infractructure required to support Avalonia windows in F# interactive, courtesy of the discussion in this issue.

Run the following script code before creating Avalonia windows.

#r "nuget: AVLoop"

open FSharp.Compiler.Interactive
open AVLoop

let install(theme) =
        fsi.EventLoop <- {new IEventLoop with 
                                member x.Run() = 
                                    createApp(theme, [||])
                                    false //dummy
                                member x.Invoke(f) = disp f
                                member x.ScheduleRestart() = () //dummy

install(Default,Dark) //wait till initialization message before submitting more code

Run the above snippent interactively first. Wait till you see a message "avalonia initialized" and then proceed to submit other code.

If you run this script along with window creation code in the same submit then that will not work. It seems the F# interactive main loop thread needs to be free to 'Run' the event loop (which actually initializes Avalonia).

Window example

Here is an example of a simple window

open Avalonia
let win1 = Controls.Window()
win1.Width <- 300
win1.Height <- 300
let btn1 = Controls.Button()
btn1.Width <- 100
btn1.Height <- 50
btn1.Content <- "Click me"
btn1.Click |> Observable.subscribe (fun _ -> btn1.Content <- "Clicked!")
win1.Content <- btn1

Product Versions
.NET net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.4.1 111 2/9/2023
1.4.0 386 1/15/2022
1.3.0 179 1/15/2022
1.1.9 170 1/13/2022