문제

dojo/on has once() which is extremely useful. How to implement such behaviour in dojo/aspect's before()/after()? I can't believe somebody implemented once() to dojo/on but not dojo/aspect. I don't see any difference.

도움이 되었습니까?

해결책

is it so difficult to save the return of before/after and call remove on it? Here's a simple implementation :

aspect.onceAfter: function(target, methodName, advice, receiveArguments){
  var handle = aspect.after(target, methodName, function(){
    handle.remove();
    advice.apply(null, arguments);
  }, receiveArguments);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top