-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update to preview6 #178
Update to preview6 #178
Conversation
.StartBrowserAppAsync("out") | ||
.Result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to return Task here without awaiting or blocking anything?
Blocking async calls isn't supported on WASM backend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, a better way is needed here, will take another look later (I am not to familiar with F#) or someone with better F# knowledge can give some hint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there is needed for better way. It just needs return a Task produced by StartBrowserAppAsync.
This code is executed by WASM interop layer, so it is expected to either return int/void or return a Task.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but StartBrowserAppAsync does not return Task<int>
and F# does need an int return of main
/AvaloniaXplatfnet70.Browser/Program.fs(20,9): error FS0193: Type constraint mismatch. The type 'Task' is not compatible with type 'int'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks to ChatGPT I found out how to do it in F#. It would be a bit nicer though if StartBrowserAppAsync would return Task<int>
instead of Task
I am also not sure which parts of this properties set here are also required for the template: https://github.com/AvaloniaUI/Avalonia/blob/master/samples/ControlCatalog.Browser/ControlCatalog.Browser.csproj |
The F# Browser problem seems to be in the dotnet.js, it breaks in the first line of it, but I don't see any error message. @maxkatz6 Should I maybe split the C# and F# update to 2 PRs so C# can at least already be updated while F# is investigated? |
As I mentioned above, WASM doesn't support sync awaitl, so operations like RunSynchronously don't make sense there. "dotnet.js" can be modified to execute a different method too.
I think we can do it.
Yeah, let's do it. |
fwiw, I've had the Avalonia.FuncUI web assembly control catalog app running with Avalonia 11 preview 6 by doing let main argv =
task {
do! buildAvaloniaApp().StartBrowserAppAsync("out")
}
|> ignore
0 Though I don't know if this is actually the 'correct' way to do it |
Also this is not yet answered:
E.g. should that |
This updates the templates to preview 6.
Browser template for C# works fine, but the F# one leads to a blank screen, not sure what's wrong there.