Property change listener in ComponentModelDelegate

Hi,

I’m making a component (in React) it uses a ComponentModelDelegate. I have tried to implement a property change listener. But when I uses the code bellow, all other props are frozen. What is the correct way of getting updated props of the component, inside of the component model delegate?

My usecase is that I pull all alarms every minute. The user of the component can add an source filter, which may depend on the sessions path. So I would like to update the filter value at each pull.

public class FooModelDelegate extends ComponentModelDelegate { 
   @Override
    public void onStartup() {
        filterSourcePathReference = component.createPropertyReference("this.props.filterSourcePath", new FilterSourcePathListener(), Origin.ANY);
        filterSourcePathReference.startup();
    }

@Override
public void onShutdown() {
        filterSourcePathReference.shutdown();
        scheduler.shutdownNow();
    }

private class FilterSourcePathListener implements Consumer<PropertyTreeChangeEvent> {
    @Override
    public void accept(PropertyTreeChangeEvent event) {
        log.info("Filter source path changed: " + event.readValue());
        String rawValue = (String) event.readValue().getValue();
        filterSourcePath = rawValue.split(",");
      }
    }

You can directly subscribe to changes of the property tree:

Component::getPropertyTreeOf
PropertyTree::subscribe

A (non-trivial) example:

1 Like