Skip to content

Commit

Permalink
docs: update docs to reflect changes introduced in rc 005
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelMunoz committed Nov 30, 2024
1 parent 9db5261 commit 9b14290
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion docs/Navs-Avalonia.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ That being said...
## Usage

[hide]
#r "nuget: Navs.Avalonia, 1.0.0-rc-002"
#r "nuget: Navs.Avalonia, 1.0.0-rc-005"
#r "nuget: FSharp.Data.Adaptive, 1.2.14"

Using this library is very similar to using the base Navs library. The main difference is that the `Navs.Avalonia` library provides a less generic versions of the API.
Expand Down
2 changes: 1 addition & 1 deletion docs/Navs-FuncUI.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ category: Libraries
---

[hide]
#r "nuget: Navs.Avalonia, 1.0.0-beta-008"
#r "nuget: Navs.Avalonia, 1.0.0-rc-005"

## Navs.FuncUI

Expand Down
28 changes: 15 additions & 13 deletions docs/Navs.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,17 @@ From there on, you can use the router to navigate to different parts of your app
*)

(*** hide ***)
#r "nuget: Navs, 1.0.0-rc-002"
#r "nuget: Navs, 1.0.0-rc-005"

open FSharp.Data.Adaptive
open System
open System.Threading.Tasks
open UrlTemplates.RouteMatcher

(*** show ***)

open Navs
open Navs.Router

module Task =

let empty = Task.FromResult(()) :> Task

type Page = {
title: string
content: string
Expand All @@ -53,7 +48,7 @@ let routes = [
fun _ _ -> {
title = "Home"
content = "Welcome to the home page"
onAction = fun () -> Task.empty
onAction = fun () -> Task.CompletedTask
}
)
Route.define<Page>(
Expand All @@ -62,7 +57,7 @@ let routes = [
fun _ _ -> {
title = "About"
content = "This is the about page"
onAction = fun () -> Task.empty
onAction = fun () -> Task.CompletedTask
}
)
]
Expand All @@ -73,7 +68,7 @@ let router =
fun () -> {
title = "Splash"
content = "Loading..."
onAction = fun () -> Task.empty
onAction = fun () -> Task.CompletedTask
}
)

Expand Down Expand Up @@ -163,7 +158,7 @@ let asyncRoute =
return {
title = "Async"
content = "This is an async route"
onAction = fun () -> Task.empty
onAction = fun () -> Task.CompletedTask
}
}
)
Expand Down Expand Up @@ -212,12 +207,16 @@ Route.define<Page>(
"param",
"/param/:id<guid>",
fun ctx _ ->
let guid = ctx.urlMatch |> UrlMatch.getFromParams<Guid> "id"
let guid =
// or ctx.getParam<Guid> "id" if that's your style
RouteContext.getParam<Guid> "id" ctx
|> ValueOption.map(_.ToString())
|> ValueOption.defaultValue "No Guid Supplied"

{
title = "Param"
content = $"This is a route with a parameter: {guid}"
onAction = fun () -> Task.empty
onAction = fun () -> Task.CompletedTask
}
)

Expand All @@ -232,7 +231,10 @@ Route.define<Page>(
"param",
"/param/:id<guid>",
fun ctx (nav: INavigable<Page>) ->
let guid = ctx.urlMatch |> UrlMatch.getFromParams<Guid> "id"
let guid =
ctx.getParam<Guid>("id")
|> ValueOption.map(_.ToString())
|> ValueOption.defaultValue "No Guid Supplied"

{
title = "Param"
Expand Down
2 changes: 1 addition & 1 deletion docs/Navs/Adapters.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ category: Navs
## Creating an adapter.

[hide]
#r "nuget: Navs, 1.0.0-rc-002"
#r "nuget: Navs, 1.0.0-rc-005"

Sometimes you may want to create a custom adapter when you know the concrete types (or the interface) that you're targeting with your router and your definitions. This is a guide on how to create an adapter for a custom type.

Expand Down
2 changes: 1 addition & 1 deletion docs/UrlTemplates.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This library specializes itself in parsing URL-like strings into structured obje
*)

(*** hide ***)
#r "nuget: UrlTemplates, 1.0.0-rc-002"
#r "nuget: UrlTemplates, 1.0.0-rc-005"

open System
(**
Expand Down

0 comments on commit 9b14290

Please sign in to comment.