tmbb
VDOM on the Server - Problems?
I’ve been looking at the possibility of implementing a server-side VDOM (Virtual Dom, like Reactjs, Vuejs, Snabbdom and onthers). The problem I see with this is the high latency of the updates, and the way it interacts with input components. Suppose you have a VDOM that returns the following (using vue-style templates):
Enter your name: <input v-model="name"></input>
<br/>
<span>Hello {{ name }}!</span>
The UI should be updated as the user types (probably debounding events, but that doesn’t change the main point).
Suppose the user types a “My Name”. The event is sent to the server, which sends the minimum delta so that the browser’s DOM is changed. But suppose now that before receiving the update, the user types “Another Name”. This can happen because latency between client and server can be arbitrarily high…
You’ll have something like this:
- User requests a page. The server sends a DOM with
name = "" - User types “My name”. The server receives an event. The server sends a new DOM with
name = "My Name" - The user types “Another Name”
- The user receives a new DOM with
name = "My Name", which overwrites the text in the input component. This is a very surprising UI change - The server receives
name = "Another Name" - The UI changes back to the previous version.
I don’t think how one can avoid this. There is a serious mismatch that will keep the client and server permanently out of sync. Althout I’ve often felt that a VDOM was superior to the approach taken by Drab (which has the concept of living assigns, and instead of re-rendering everything and diffing the result updates parts of templates that correspond to specific mutations), now I’m not so sure, because of the way the network latency messes with the input components’ updates…
I’m not aware of any widely used server-side VDOM, so I don’t know if anyone has managed to find a way around this limitation.
Most Liked
LostKobrakai
Why do you want to handle user input live on the server? The only common case I can see using something like that would be live search results.
peerreynders
grych
I’ve never heard about mutation watchers before, this is why I doubt I am using it in Drab. But it always may be an issue with a terminology.
I am afraid Drab is not so sophisticated. It uses something I may call “naive direct updaters” than “mutation watchers” ![]()
Popular in Discussions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









