Search in sources :

Example 1 with Command

use of com.vaadin.client.Command in project flow by vaadin.

the class SimpleElementBindingStrategy method listenToSubPropertiesChanges.

private void listenToSubPropertiesChanges(Element htmlNode, String polymerModelPath, int subNodeIndex, Object item) {
    if (item instanceof StateNode) {
        StateNode stateNode = (StateNode) item;
        NodeMap feature = null;
        if (stateNode.hasFeature(NodeFeatures.ELEMENT_PROPERTIES)) {
            feature = stateNode.getMap(NodeFeatures.ELEMENT_PROPERTIES);
        } else if (stateNode.hasFeature(NodeFeatures.BASIC_TYPE_VALUE)) {
            feature = stateNode.getMap(NodeFeatures.BASIC_TYPE_VALUE);
        }
        if (feature != null) {
            feature.addPropertyAddListener(event -> {
                Command command = () -> PolymerUtils.setListValueByIndex(htmlNode, polymerModelPath, subNodeIndex, PolymerUtils.convertToJson(event.getProperty()));
                invokeWhenNodeIsConstructed(command, stateNode);
            });
        }
    }
}
Also used : Command(com.vaadin.client.Command) StateNode(com.vaadin.client.flow.StateNode) NodeMap(com.vaadin.client.flow.nodefeature.NodeMap)

Example 2 with Command

use of com.vaadin.client.Command in project flow by vaadin.

the class SimpleElementBindingStrategy method bindModelProperties.

private void bindModelProperties(StateNode stateNode, Element htmlNode, String path) {
    Command command = () -> stateNode.getMap(NodeFeatures.ELEMENT_PROPERTIES).forEachProperty((property, key) -> bindSubProperty(stateNode, htmlNode, path, property));
    invokeWhenNodeIsConstructed(command, stateNode);
}
Also used : Command(com.vaadin.client.Command)

Aggregations

Command (com.vaadin.client.Command)2 StateNode (com.vaadin.client.flow.StateNode)1 NodeMap (com.vaadin.client.flow.nodefeature.NodeMap)1