I created a javascript extension using AbstractJavaScriptExtension
Works fine.
Now i try to optimize the data transport between the server and client.
For example my state (JavaScriptExtensionState) has multiple objects and an array of items.
The client needs to get all the data the first time.
But after when he add an item, i want the server sends the client the new item who was created.
so i need to do this without sending all the state. (changing getState().)
i guessed i could do it on calling a js function from the server with the new item in argument.
Example in the JavaScriptExtensionState:
public void reloadLine(Line line){
callFunction("reloadLine", JsonCodec.encode(ligne, null, Line.class, UI.getCurrent().getConnectorTracker()).getEncodedValue());
}
This calls my js function properly and do the job in the client side.
But this fires the onStateChange event too.
And in the console i see that all the state has been sent (encoded in json).
These data are useless and will slow the network.
is there a way that the server communicates with the client without sending all the state ?
function myUpdateFunction(test){
globalVar.myUpdateFunction(test);
}
I think i can fix that this way. But will have to handle json encode and decode my way too.
So some code i shouldn’t have to wrote.
The js extension did all. just the call function shouldn’t be part of the state in my opinion.
but thinks there is no way to change that and that is the limitation of rpc/gwt
Yeah, I agree that there should be an easier way to do this. I don’t think there’s anything that forces updating the state, it’s just the way it has been implemented. But hopefully you can find a workaround!