質問

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