-
Notifications
You must be signed in to change notification settings - Fork 169
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
Synchronize client property changes correctly to the server #3425
Comments
As @Legioth suggested, it can be done by sending an extra info to the client about the template presence: since the model is present for templates only, we can use this information and sync automatically only properties that are relevant to Polymer elements with templates. As an alternative suggestion from @denis-anisimov , we should write all the model properties info similar to whe way we do it partially in flow/flow-server/src/main/java/com/vaadin/flow/component/polymertemplate/PolymerTemplate.java Line 190 in fc04c2d
into separate list and check this list instead. |
I don't think it's the solution. So the code should work in the same way as it worked before the change in #3420 but the code which listen all property changes should work for only model properties . There is at least one reason to do that: we can't synchronize subproperties. And we want to get updates for any subproperty change. So no, let's not synchronize explicitly every model property. |
Right, that's what I've meant, thanks for clarification.
|
You mean by |
* Add a generic way to store data inside StateNode Part of the fix for #3425 * Gwt unit test and rename method
Currently Flow has two ways of synchronizing properties to the server.
One synchronization happens for each polymer element:
https://github.com/vaadin/flow/blob/master/flow-client/src/main/java/com/vaadin/client/flow/binding/SimpleElementBindingStrategy.java#L264
every property that is defined on the server side is synchronized on each change on the client.
The other synchronization happens for each property that was explicitly set to be sync on some particular event (disregarding of the nature of the element: it can be polymer element, can be simple element):
https://github.com/vaadin/flow/blob/master/flow-client/src/main/java/com/vaadin/client/flow/binding/SimpleElementBindingStrategy.java#L602
The problem with the approach is that now, for Polymer elements, there is no way to make any property being synchronized on some particular event: the first synchronization will update it always, on any change.
To avoid this, a stub was introduced in #3420
Now first synchronization is skipped, if the property changed is set to be synced on some particular event.
Although working currently, this is not the correct way to do it: instead, we don't need to synchronize every property for polymer object in the first case at all: we need to synchronize the model properties only in the first case.
But implementing it this way will break some existing components in Flow tests at least, for instance: https://github.com/vaadin/flow/blob/1a495adefbbc4afcfb9d0b30a67c2f7ce8e5fc61/flow-tests/test-root-context/src/test/java/com/vaadin/flow/uitest/ui/webcomponent/PaperSliderIT.java
The solution to such cases is to synchronize properties required manually.
Also, the stub introduced in #3420 should be removed.
The text was updated successfully, but these errors were encountered: