use of com.vaadin.client.flow.reactive.Computation in project flow by vaadin.
the class SimpleElementBindingStrategy method bindEventHandlerProperty.
private void bindEventHandlerProperty(MapProperty eventHandlerProperty, BindingContext context) {
String name = eventHandlerProperty.getName();
assert !context.listenerBindings.has(name);
Computation computation = Reactive.runWhenDependenciesChange(() -> {
boolean hasValue = eventHandlerProperty.hasValue();
boolean hasListener = context.listenerRemovers.has(name);
if (hasValue != hasListener) {
if (hasValue) {
addEventHandler(name, context);
} else {
removeEventHandler(name, context);
}
}
});
context.listenerBindings.set(name, computation);
}
use of com.vaadin.client.flow.reactive.Computation in project flow by vaadin.
the class ChildSlotBindingStrategy method bind.
@Override
protected void bind(StateNode modelNode, Node anchor, int templateId, TemplateBinderContext context) {
Computation computation = Reactive.runWhenDependenciesChange(new ChildSlotBinder(context, anchor, modelNode));
modelNode.addUnregisterListener(e -> computation.stop());
}
use of com.vaadin.client.flow.reactive.Computation in project flow by vaadin.
the class SimpleElementBindingStrategy method bindProperty.
private static void bindProperty(PropertyUser user, MapProperty property, JsMap<String, Computation> bindings) {
String name = property.getName();
assert !bindings.has(name) : "There's already a binding for " + name;
Computation computation = Reactive.runWhenDependenciesChange(() -> user.use(property));
bindings.set(name, computation);
}
use of com.vaadin.client.flow.reactive.Computation in project flow by vaadin.
the class SimpleElementBindingStrategy method invokeWhenNodeIsConstructed.
private void invokeWhenNodeIsConstructed(Command command, StateNode node) {
Computation computation = Reactive.runWhenDependenciesChange(command);
node.addUnregisterListener(event -> computation.stop());
}
use of com.vaadin.client.flow.reactive.Computation in project flow by vaadin.
the class TextBindingStrategy method bind.
@Override
public void bind(StateNode stateNode, Text htmlNode, BinderContext nodeFactory) {
assert stateNode.hasFeature(NodeFeatures.TEXT_NODE);
if (BOUND.has(stateNode)) {
return;
}
BOUND.set(stateNode, true);
NodeMap textMap = stateNode.getMap(NodeFeatures.TEXT_NODE);
MapProperty textProperty = textMap.getProperty(NodeProperties.TEXT);
Computation computation = Reactive.runWhenDependenciesChange(() -> htmlNode.setData((String) textProperty.getValue()));
stateNode.addUnregisterListener(e -> unbind(stateNode, computation));
}
Aggregations