Frage

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.

War es hilfreich?

Lösung

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);
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top