Vaadin Shared State

Hello everybody.

My collegue found very interesting behaviour of shared state.

We use class Wrapper to wrap some other classes, and one of them contains simple data boolean, boolean, id (unique) - for example we named it TestClass

On server side we set TestClass with false, false, 1 - it fly to client, we store it to local storage, do stuff and in process we change flag to true. So the TestClass is true, false, 1… ok…

Next call to server… we get new TestClass: false, false, 2… but on client side stateChangeEvent give us this:
TestClass: true, false, 2

​Any suggestions where we do problem or where is the problem?

Shared state is one way, server → client only.

If you want to update the state from the client then you should do a client → server RPC for the update instead of updating it in the state object.

Hi i know this.

We are not trying to update state from client to server… we only want to get new data, store them to local storage of browser and work with them…

But the problem is that on server side we put new correct data and vaadin fire this data to client… but on client side are incorrect at moment when stateChangeEvent is fired.

So my question is where is problem that server side is firing correct data, but client side is catching (or showing) incorrect data.

You wrote: "do stuff and in process we change flag to true. So the TestClass is true, false, 1… ok… "
So it sounds like you’re actually changing the class from the state on the client which might cause the problem you’re having.

Generally speaking it’s probably something in your code which is causing it and not Vaadin shared state so without a good idea on what you’re doing it’ll be difficult to find the cause.

Ok guys i see the problem now… we are not using our mechanism correctly…

get new data, store them in local storage and after that we create this object if needed.

instead collegue used direct object from state…

My fault … sorry for bothering, but you open my eyes and i find the problem quicker :slight_smile: thanks