Comments (4)
Hi,
Thanks for the comment -- I'm one of the implementers of UI.Next, and it's always good to see user comments!
Unfortunately, there are a couple of reasons why I don't support this proposal. In particular, the main reason for this is that Vars of say, unit type, can be set in order to trigger a callback function. By setting a Var of unit type's value as (), for example, a function in a Sink can be triggered, which is a useful pattern in some circumstances. Indeed, this would break the implementations of SnapshotOn and UpdateWhile (although these may be revisited in future -- we have plans to look at Hopac-style concurrency abstractions for event handling at some point).
For a similar reason, the second suggestion wouldn't work. Indeed, the implementation of the dataflow->DOM integration relies on views of unit type being triggered, so if this was done, the entire system would break :) Have a look here for an example of what I mean: https://github.com/intellifactory/websharper.ui.next/blob/master/WebSharper.UI.Next/Doc.fs#L356
It might be an idea to introduce specialised versions of Vars and Views which have more specific properties regarding updates, for example only triggering when the value is different.
Regarding not unnecessarily creating DOM elements, this functionality is implemented already and the preservation of node identity was an important part of the design. If you use the View.Convert
family of functions instead of Map
, you can preserve DOM elements when something changes. Take a look at around 27:00 of Anton Tayanovskyy's tutorial, https://www.youtube.com/watch?v=wEkS09s3KBc, the Documentation on Sharing, and the TODO List Example.
On the other hand, I think your pull request for the form component certainly looks reasonable and should work. I'll have a play with it once I'm back on my Windows laptop!
Thanks again, and sorry it took me a while to reply.
from ui.
Hi Simon,
Thank you for the detailed explanation and code pointers. I certainly don't want to break the system - I love it :)
I was misled by the fact that my experimenting with the Var implementation by adding an equality check on Set (which did involve introducing a number of cascading type restrictions) did both build and appeared to work in my application (which does not hit the Sink execution path you've mentioned). This led me to wonder whether the behavior could be extended to the view updates.
I will move to use View.Convert in the code where I am now performing manual checks - thanks again!
from ui.
Thanks for the response, and glad you're enjoying UI.Next!
Great -- hope it works out. Please let me know!
from ui.
It did work out, and beautifully so :)
'''Document.Convert''' proved to be the simplest solution in my case - the Convert
family of functions works like a charm 👍
Regarding the pull request: I'm now using a fork of UI.Next with that particular change included and haven't seen any ill effects. I hope you can include it in the next nuget version, it would save me the headache of maintaining a separate fork.
Thank you for your help - Convert
is a very nice way to deal with time-varying collections in a sane manner - I should have read the docs more carefully :)
from ui.
Related Issues (20)
- Update function for a var causes ambiguity in C#
- Add a `Doc.Hydrate` helper, similar to `Doc.ClientSide` that also renders server-side content
- Fix unwanted caching within WS compiler service
- Doc.ClientSide should auto-quote HOT 1
- Ease syntax for server-client bridge in markup HOT 4
- Obsolete `client` HOT 2
- Update CONTRIBUTING.md HOT 1
- `ws-preserve` in templates produces garbage in output
- Add a `ws-anchor` attribute for TP
- Add new variant for OnAfterRender handler bound in server-side code
- Extend templating with HTML5 templates HOT 1
- Error while building on Linux HOT 1
- Could not detect any platforms from 'net6.0' warnings
- Make WebSharper.UI.Templating a design-time only assembly
- Updated ViewCE
- Add `Content.PageFragment`
- Add overloads with optional extra content headers and status code for `Content.Page*` HOT 1
- Bundling error in WS 6.1.2.265 - 6.1.4.277 when dead code elimination is enabled HOT 13
- Doc.InputType.Int returns Invalid "" for all invalid values HOT 1
- Binding event handlers in server-side code
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ui.