Skip to content

Commit

Permalink
#1266 obsolete ClientSide
Browse files Browse the repository at this point in the history
  • Loading branch information
Jand42 committed Oct 1, 2022
1 parent 5a05a75 commit 18d2511
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 22 deletions.
14 changes: 9 additions & 5 deletions src/sitelets/WebSharper.Web/Control.fs
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,9 @@ module ClientSideInternals =

open ClientSideInternals

/// Implements a web control based on a quotation-wrapped top-level body.
/// Use the function ClientSide or ctx.ClientSide to create an InlineControl.
/// Embed the given client-side control body in a server-side control.

This comment has been minimized.

Copy link
@granicz

granicz Oct 3, 2022

Member

We should use third person mode in comments, "Embeds ...", etc.

/// The client-side control body must be an implicit or explicit quotation expression.
/// It can capture local variables, of the same types which are serializable by WebSharper as RPC results.
[<CompiledName "FSharpInlineControl">]
type InlineControl<'T when 'T :> IControlBody>(elt: Expr<'T>) =
inherit Control()
Expand Down Expand Up @@ -330,6 +331,11 @@ type InlineControl<'T when 'T :> IControlBody>(elt: Expr<'T>) =
member this.Encode(meta, json) =
[this.ID, json.GetEncoder(this.GetType()).Encode this]

/// Embed the given client-side control body in a server-side control.
/// The client-side control body must be an implicit or explicit quotation expression.
/// It can capture local variables, of the same types which are serializable by WebSharper as RPC results.
static member Create<'T when 'T :> IControlBody> ([<JavaScript; ReflectedDefinition>] e: Expr<'T>) =

This comment has been minimized.

Copy link
@granicz

granicz Oct 3, 2022

Member

There is pending work about fixing up constructors, once that's completed this should be moved to InlineControl(...). Bump to 6.1 as this is a breaking change.

new InlineControl<'T>(e)

open System
open System.Reflection
Expand Down Expand Up @@ -435,8 +441,6 @@ module WebExtensions =
open Microsoft.FSharp.Quotations
open WebSharper.Web

/// Embed the given client-side control body in a server-side control.
/// The client-side control body must be an implicit or explicit quotation expression.
/// It can capture local variables, of the same types which are serializable by WebSharper as RPC results.
[<System.Obsolete "Use `WebSharper.Web.InlineControl.Create` instead">]

This comment has been minimized.

Copy link
@granicz

granicz Oct 3, 2022

Member

See comment about removing .Create from the call.

let ClientSide ([<JavaScript; ReflectedDefinition>] e: Expr<#IControlBody>) =
new InlineControl<_>(e)
10 changes: 5 additions & 5 deletions tests/WebSharper.Sitelets.Tests/SampleSite.fs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ module SampleSite =
yield! t.Login
yield! t.Menu
yield! t.Body
yield ClientSide <@ Client.Widget () @> :> _
yield Web.InlineControl.Create ( Client.Widget () ) :> _
]
)
}
Expand Down Expand Up @@ -233,18 +233,18 @@ module SampleSite =
[
Elt("h1", Text "Welcome to our site!")
"Let us know how we can contact you" => ctx.Link Action.Contact
Elt("div", ClientSide <@ Client.Elt "b" [|Client.Text "It's working baby"|] @>)
Elt("div", Web.InlineControl.Create (Client.Elt "b" [|Client.Text "It's working baby"|] ))
Elt("div",
Text """This should say 'Checking "attribute" encoding':""",
Elt("input", Attr("placeholder", """Checking "attribute" encoding"""))
)
Elt("div",
ClientSide
<@ Client.Elt "i" [|
Web.InlineControl.Create
( Client.Elt "i" [|
Client.Text "On the "
Client.Elt "b" [|Client.Text "client side"|]
Client.Text " too!"
|] @>)
|] ))
]

/// A page to collect contact information.
Expand Down
8 changes: 4 additions & 4 deletions tests/WebSharper.StaticHtml.Tests.NetStandard/Main.fs
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,18 @@ module Site =
Body = [
Elt("h1", Text "Welcome to our site!")
"About us" => ctx.Link EndPoint.About
Elt("div", ClientSide <@ Client.Elt "b" [|Client.Text "It's working baby"|] @>)
Elt("div", Web.InlineControl.Create ( Client.Elt "b" [|Client.Text "It's working baby"|] ))
Elt("div",
Text """This should say 'Checking "attribute" encoding':""",
Elt("input", Attr("placeholder", """Checking "attribute" encoding"""))
)
Elt("div",
ClientSide
<@ Client.Elt "i" [|
Web.InlineControl.Create
( Client.Elt "i" [|
Client.Text "On the "
Client.Elt "b" [|Client.Text "client side"|]
Client.Text " too!"
|] @>)
|] ))
Elt("div", ClientSide <@ Client.Main() @>)
]
)
Expand Down
16 changes: 8 additions & 8 deletions tests/Website/Content.fs
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,16 @@ let TestsPage runServerTests autoStart (ctx: Context<FullAction>) =
Title = "WebSharper client-side tests",
Body = (
[
yield ClientSide <@ WebSharper.Tests.Main.RunTests runServerTests autoStart @> :> Web.Control
yield ClientSide <@ WebSharper.Collections.Tests.Main.RunTests() @> :> Web.Control
yield Web.InlineControl.Create ( WebSharper.Tests.Main.RunTests runServerTests autoStart ) :> Web.Control
yield Web.InlineControl.Create ( WebSharper.Collections.Tests.Main.RunTests() ) :> Web.Control
yield WebSharper.CSharp.Tests.InlineControlTest.RunTestsControl runServerTests
yield ClientSide <@ Client.ClientSideTupleTest t12 @> :> Web.Control
yield ClientSide <@ WebSharper.Html5.Tests.Main.RunTests true @> :> Web.Control
yield ClientSide <@ WebSharper.Sitelets.Tests.ClientServerTests.RunTests apiBaseUri corsBaseUri runServerTests @> :> Web.Control
yield Web.InlineControl.Create ( Client.ClientSideTupleTest t12 ) :> Web.Control
yield Web.InlineControl.Create ( WebSharper.Html5.Tests.Main.RunTests true ) :> Web.Control
yield Web.InlineControl.Create ( WebSharper.Sitelets.Tests.ClientServerTests.RunTests apiBaseUri corsBaseUri runServerTests ) :> Web.Control
if runServerTests then
yield ClientSide <@ WebSharper.Sitelets.Tests.ApiTests.RunTests apiBaseUri @> :> Web.Control
yield ClientSide <@ WebSharper.Module.Tests.Main.RunTests() @> :> Web.Control
yield ClientSide <@ WebSharperWebTestsMain.RunTests jsonBaseUri runServerTests @> :> Web.Control
yield Web.InlineControl.Create ( WebSharper.Sitelets.Tests.ApiTests.RunTests apiBaseUri ) :> Web.Control
yield Web.InlineControl.Create ( WebSharper.Module.Tests.Main.RunTests() ) :> Web.Control
yield Web.InlineControl.Create ( WebSharperWebTestsMain.RunTests jsonBaseUri runServerTests ) :> Web.Control
] : list<Web.Control>
)
)
Expand Down

0 comments on commit 18d2511

Please sign in to comment.