2
似乎MATLAB句柄一次不会响应来自同一个源的多个通知。不幸的是,这对我来说是个大问题。下面是我在说什么的例子:MATLAB嵌套事件通知?
classdef testClass < handle
events
testevent
end
methods
function obj = testClass
obj.addlistener('testevent', @obj.respond);
end
function raise(obj)
obj.notify('testevent');
end
function respond(obj, varargin)
fprintf('Responded!\n');
obj.raise();
end
end
end
当我执行的代码
c = testClass;
c.raise();
结果是
Responded!
但我真正想要的递归工作,虽然显然在这个简单的例子中,它会无限递归。有没有办法得到这种行为?
太棒了!谢谢,那正是我需要的! – rlbond
你已经度过了我的一天! – CitizenInsane