addlistener
Subscribe a callback to an event of a handle object.
Syntax
Section titled “Syntax”hl = addlistener(Hsource, EventName, callback)hl = addlistener(Hsource, PropName, EventName, callback)Description
Section titled “Description”Attaches callback (a function handle) to the named event EventName on the handle object Hsource. The returned listener handle hl controls the subscription — let it go out of scope (or call delete(hl)) to unsubscribe.
The four-argument form attaches a property-change listener: EventName is one of 'PreSet', 'PostSet', 'PreGet', 'PostGet'.
Example
Section titled “Example”hl = addlistener(obj, 'StateChanged', @(src,evt) disp('changed'));