-
Notifications
You must be signed in to change notification settings - Fork 22
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
Questions about Var and View updates #3
Comments
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 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. |
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! |
Thanks for the response, and glad you're enjoying UI.Next! Great -- hope it works out. Please let me know! |
It did work out, and beautifully so :) '''Document.Convert''' proved to be the simplest solution in my case - the 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 - |
Hi,
I was wondering what are your thoughts on:
I was wondering if you would be partial to introducing an internal check for equality in the Var.Set function
If so, I can create a pull request.
For example, given a function f: a-> b that can yield the same b for distinct values of a and a view A: View, should one create a view B as View.Map f A, one would observe spurious View B updates (i.e successive updates of View B, say with the values bx and by even though bx = by )
Given my current understanding of UI.Next, I think addressing this would require changing the Snap implementation. This would be helpful in simplifying client code (right now I need to perform these checks in functions generating the UI, to avoid unnecessarily recreating DOM elements)
Are you open to such a change?
The text was updated successfully, but these errors were encountered: