A set of libraries that allow Router-like experiences for general purpose F# Apps
MIT License
Bot releases are visible (Hide)
Nothing too crazy
Full Changelog: https://github.com/AngelMunoz/Navs/compare/v1.0.0-beta-008...v1.0.0-rc-001
Published by AngelMunoz 7 months ago
Full Changelog: https://github.com/AngelMunoz/Navs/compare/v1.0.0-beta-007...v1.0.0-beta-008
Published by AngelMunoz 7 months ago
Full Changelog: https://github.com/AngelMunoz/Navs/compare/v1.0.0-beta-006...v1.0.0-beta-007
Published by AngelMunoz 7 months ago
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: https://github.com/AngelMunoz/Navs/compare/v1.0.0-beta-005...v1.0.0-beta-006
Published by AngelMunoz 8 months ago
Full Changelog: https://github.com/AngelMunoz/Navs/compare/v1.0.0-beta-004...v1.0.0-beta-005
Published by AngelMunoz 8 months ago
UrlMatch
Utility functions to extract values from the parametersHere's a sample of that from the new Tests project
Note: These functions are extension methods, but standard F# functions are also available.
test "UrlMatchExtensions.getParamSeqFromQuery can return a sequence of query params" {
let template = "/api?name&age<int>&statuses"
let url = "/api?name=john&age=30&statuses=active&statuses=inactive"
let _, _, urlMatch =
RouteMatcher.matchStrings template url
|> Result.defaultWith(fun e ->
failtestf "Expected Ok, got Error %A" e
)
let name = urlMatch.getFromParams<string>("name")
let age = urlMatch.getFromParams<int>("age")
let values = urlMatch.getParamSeqFromQuery<string>("statuses")
let statuses = values |> ValueOption.defaultValue Seq.empty
Expect.equal name (ValueSome "john") "name should match"
Expect.equal age (ValueSome 30) "age should match"
Expect.sequenceContainsOrder
statuses
(seq {
"inactive"
"active"
})
"statuses should match"
}```
**Full Changelog**: https://github.com/AngelMunoz/Navs/compare/v1.0.0-beta-003...v1.0.0-beta-004
Published by AngelMunoz 8 months ago
In order to enable navigations within the handlers it has been added as a parameter
// Before
Route.define<_>("home", "/", (fun _ ->
// unable to navigate here as you'd need a router reference and it can't be created before routes are defined
))
// After
Route.define<_>("home", "/", (fun (_, nav) ->
return
UIElement
.content(
Label().text("My Text")
Button().onClick(fun _ -> nav.NavigateByName("home") |> ignore)
)
))
Full Changelog: https://github.com/AngelMunoz/Navs/compare/v1.0.0-beta-002...v1.0.0-beta-003
Published by AngelMunoz 8 months ago
Fixed a situation where QueryParams in templated URLs were not allowed to use -
or _
in thgeir name
Full Changelog: https://github.com/AngelMunoz/Navs/compare/v1.0.0-beta-001...v1.0.0-beta-002
Published by AngelMunoz 8 months ago
This is the first release of the Navs Family
Documentation and other missing stuff is going to come soon, but feel free to start checking it out and provide some feedback if you think this might be useful for you!
The best place to look for usages is the samples folder which contains a few examples on how to use Nav with NXUI and FuncUI both for Avalonia