ajuch
ajuch

Reputation: 415

Linking to endpoints from the client-side in WebSharper

In sitelets it's rather easy to create links to other endpoints with parameters. For example ctx.Link(EndPoint.ShowUser user.id)) creates a link to the ShowUser endpoint with a specific ID.

Now I'm migrating some code to the client side to dynamically update a table once a new item is created; the table has action links that point to other endpoints. Is there something like ctx.Link on the client side I can use?

I'd rather avoid creating the link by myself (e.g. with sprintf) because I want the EndPoint type to be authorative for everything URL related.

Upvotes: 1

Views: 134

Answers (1)

Tarmil
Tarmil

Reputation: 11362

You can create a Router<EndPoint> value on the client side and use it to create links:

open WebSharper.Sitelets.InferRouter

let router = Router.Infer<EndPoint>()

let link = router.Link(EndPoint.ShowUser user.id)

Upvotes: 2

Related Questions