use of com.vaadin.client.flow.StateTree in project flow by vaadin.
the class GwtAtmoshperePushConnectionTest method gwtSetUp.
@Override
protected void gwtSetUp() throws Exception {
super.gwtSetUp();
initScheduler(new CustomScheduler());
registry = new Registry() {
{
set(ConstantPool.class, new ConstantPool());
set(StateTree.class, new StateTree(this));
set(URIResolver.class, new URIResolver(this));
set(UILifecycle.class, new UILifecycle());
set(ApplicationConfiguration.class, new ApplicationConfiguration());
set(MessageHandler.class, new MessageHandler(this));
set(PushConfiguration.class, new PushConfiguration(this) {
@Override
public JsMap<String, String> getParameters() {
return JsCollections.map();
}
});
set(ConnectionStateHandler.class, new DefaultConnectionStateHandler(this));
}
};
}
use of com.vaadin.client.flow.StateTree in project flow by vaadin.
the class MapProperty method getSyncToServerCommand.
/**
* Sets the value of this property and returns a synch to server command.
*
* @param newValue
* the new value to set.
* @see #syncToServer(Object)
*/
public Runnable getSyncToServerCommand(Object newValue) {
Object currentValue = hasValue() ? getValue() : null;
if (Objects.equals(newValue, currentValue)) {
// in case we are here with the same value that has been set from
// the server then we unlock client side updates already here via
// unmarking the server update flag. It allows another client side
// potential change for the same property being propagated to the
// server once the server value is set successfully (e.g. mutation
// the same property from its observer).
isServerUpdate = false;
}
if (!(Objects.equals(newValue, currentValue) && hasValue()) && !isServerUpdate) {
StateNode node = getMap().getNode();
StateTree tree = node.getTree();
if (tree.isActive(node)) {
doSetValue(newValue);
return () -> tree.sendNodePropertySyncToServer(this);
} else {
/*
* Fire an fake event to reset the property value back in the
* DOM element: we don't know how exactly set this property but
* it has to be set to the property value because of listener
* added to the property during binding.
*/
eventRouter.fireEvent(new MapPropertyChangeEvent(this, currentValue, currentValue));
// Flush is needed because we are out of normal lifecycle which
// call the flush() automatically.
Reactive.flush();
}
}
return NO_OP;
}
Aggregations