MATLAB: How To listen to a list of properties and call a method when a property of that list changes value

eventlistenerMATLABoop

Hi,
I would like to automatically call a method when some class properties do change.
I have been able to do it for in single property:
mySetup.rwConfigChangeListener = event.proplistener(mySetup,{'rwConfig'},'PostSet', @mySetup.ResetRwAoaToMin);
But now I need a method to be called anytime one of 50 prop do change.
Documentation seems to indicate I should be able to input a list of properties, but I have not been able to do so:
lh = event.proplistener(Hobj,Properties,'PropEvent',@CallbackFunction) creates a property listener object for one or more properties on the specified object.
Hobj — handle of object whose property or properties are to be listened to. If Hobj is an array, the listener responds to the named event on all objects in the array.
Properties — an object array or a cell array of meta.property object handles representing the properties to which you want to listen.
PropEvent — must be one of the strings: PreSet, PostSet, PreGet, PostGet
@CallbackFunction function handle to the callback function that executes when the event occurs.
Also maybe I should use a different kind of listener?
Thanks for your help.

Best Answer

You have to build the meta property list from the metaclass:
p = IHaveProps;
mc = metaclass(p);
metaprops = [mc(:).Properties];
listener = event.proplistener(p, metaprops, 'PostSet', @(~,evt)disp(evt))
p.Property1 = pi
p.Property2 = exp(1)
For the class:
classdef IHaveProps < handle
properties (SetObservable)
Property1
Property2
PropertyTuesday
end
end