C# Support
UI Samples in C#
These samples demonstrate how to use WebSharper.UI to build reactive web applications in C#. You can compare them with the F# equivalents.
Reactive variables
Differences from F#:
View.Map2
is available as an extension method instead of a static method.Var
s andView
s can be embedded as content directly in HTML combinators likediv
button
has a simplified overload that accepts the text and action directly.
Shorthand Views with .V
- Lensing on C# records is supported, so
input(state.V.Name)
creates aninput
element with two-way immutable binding to theName
property of thestate
record. - Instead of a
V
function, theV.V
helper is used to create reactive expressions.
HTML templates
- The C# version sets
ClientLoad = FromDocument
in a HTML comment, for the templating code generator to use. - The
ListModel
type requires a key for each element, so we use a C# tuple with named elements. - C# template holes do not automatically support the
.V
shorthand, so theV.V
helper is used.
Client-side routing
- The endpoints must be declared as a base class, and subclasses that are nested inside it. This enables
Router.Infer
to work. - Fullly qualified names are used for the
Router
andDoc
types for disambiguation. This is intended to be improved in the future. See the issue.