v1.0.0-beta-006
·
39 commits
to main
since this release
What's Changed
- Update types and rework router functionality by in #4
This release includes some breaking changes required to stabilize the API at last specially around handler parameters.
but I don't expect more breaking changes from now on unless I find more corner cases while creating sample apps.
Speaking of sample apps, the Navs.Avalonia package includes FSharp.Data.Adaptive extensions and utility functions so you can integrate seamlessly from both C# and F# while staying true to each language's idioms.
I tried to be as flexible and pragmatic as I can be, here's an example of a counter in both languages.
using FSharp.Data.Adaptive;
using CSharp.Data.Adaptive;
using Navs;
using UrlTemplates.RouteMatcher;
using Navs.Avalonia;
using Navs.Interop;
using Route = Navs.Avalonia.Interop.Route;
using static Navs.Avalonia.AVal.Interop;
Route.Define("home", "/", (_ , _) => {
var (count, setCount) = UseState(0);
return StackPanel()
.Spacing(8)
.Children(
TextBlock().Text("Home"),
TextBlock().Text(count.Map(value => $"Count: {value}").ToBinding()),
Button().Content("Increment").OnClickHandler((_, _) => setCount(count => count + 1)),
Button().Content("Decrement").OnClickHandler((_, _) => setCount(count => count - 1)),
Button().Content("Reset").OnClickHandler((_, _) => setCount(_ => 0))
);
}),Route.define("home", "/", fun _ _ -> {
let (count, setCount) = AVal.useState 0
return StackPanel()
.spacing(8)
.children(
TextBlock().text("Home"),
TextBlock().text(
adaptive {
let! count = count
return $"Count: {value}"
}
// or count |> AVal.map (fun count -> $"Count: {count}")
|> AVal.toBinding
),
Button().content("Increment").OnClickHandler((_, _) => setCount(fun count -> count + 1)),
Button().content("Decrement").OnClickHandler((_, _) -> setCount(fun count -> count - 1)),
Button().content("Reset").OnClickHandler((_, _) -> setCount(fun _ -> 0))
)
})it is easier now to use adaptive data to manage local state
Full Changelog: v1.0.0-beta-005...v1.0.0-beta-006