Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ease syntax for server-client bridge in markup #240

Closed
granicz opened this issue Sep 29, 2022 · 4 comments
Closed

Ease syntax for server-client bridge in markup #240

granicz opened this issue Sep 29, 2022 · 4 comments

Comments

@granicz
Copy link
Member

granicz commented Sep 29, 2022

When constructing server-side HTML with dynamic, client-side content/functionality, we rely on client/clientSide/Doc.Hydrate to embed client-side content, and historically we required explicit quotations <@ ... @> around the client-side expression. The reasoning was "to mark the server-client bridge so it stands out."

This ticket is to extend the API to allow for variants of the above functions not to require explicit quotations, as to remove the "strangeness" factor associated with the quotation symbols.

Given F#'s current limitation of having auto-quotation available only on members of a type, one proposal would be to make these functions available as Doc.Client, Doc.ClientSide (already "there" but needs to a member, filed as #239), and Doc.Hydrate (already there).

@granicz
Copy link
Member Author

granicz commented Oct 4, 2022

More thoughts we should take into consideration:

  1. Old code using client <@ ... @> should receive warnings to help migrating to the newer syntax.
  2. Changing to the new syntax should not require name changes, unless the old name is obscure.
  3. client, Doc.Hydrate, and any other function dealing with mixed tiers, are special functions and they need to be named and placed accordingly.
  4. We should clear up/standardize how to refer to mixed-tier functions (client/ClientSide/Doc.ClientSide/Doc.Hydrate/etc.)

Based on these, I think the following makes most sense:

  1. Creating a new holder class (proposal is WebSharper.UI.ClientServer) with static members (named with lowercase to denote significance), applying auto-quoting where appropriate:
    a. client
    b. clientLinq
    c. hydrate
  2. Obsoleting the original functions with a reference to the new counterparts:
    a. client -> use ClientServer.client (and revise Obsolete client #241)
    b. Doc.ClientSide -> use ClientServer.client (and revise Doc.ClientSide should auto-quote #239)
    c. Doc.Hydrate (too bad as this was just recently introduced) -> use ClientServer.hydrate
    d. ClientSide (the alias to InlineControl) -> use InlineControl(...)
    e. Doc.ClientSideLinq -> use ClientServer.clientLinq
  3. Giving guidance in the documentation about migrating to the new syntax:
    a. Use open type WebSharper.UI.ClientServer to override the old syntax and to require the new one
    b. Old code can also reference the new functions from ClientServer.* directly.

@Jand42
Copy link
Member

Jand42 commented Oct 4, 2022

@granicz ClientSideLinq is for C# use, already aliased for C# as client to look same as F#. Not really worth aliasing for F# use.

@granicz
Copy link
Member Author

granicz commented Oct 4, 2022

@Jand42 This ticket is not about who uses those functions but from where. There is now a separate place for mixed-tier functions, and clientLinq belongs there too. And yes, the C# alias should point to the new place.

@granicz
Copy link
Member Author

granicz commented Oct 16, 2022

ClientServer.* needs XMLDOC comments to describe what they do - not sure how we missed these...

@granicz granicz reopened this Oct 16, 2022
Jooseppi12 added a commit that referenced this issue Oct 18, 2022
granicz added a commit that referenced this issue Oct 19, 2022
* #240 Xml doc
* fix up comments
* Update Doc.fsi
* Tamed the XMLDOC comments on `ClientServer.*` somewhat. Still pretty technical.
* XMLDOC on the enclosing type too

Co-authored-by: András Jankó <andras.janko@gmail.com>
Co-authored-by: Adam Granicz <adam.granicz@gmail.com>
@granicz granicz added this to High priority for current version in Releases Nov 16, 2022
@Jand42 Jand42 closed this as completed Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Releases
High priority for current version
Development

No branches or pull requests

3 participants