Jerry,
I use dojo on.once quit often in code.
on.once(map, "update-end", function(){
// will only fire once...
});
Hello Jerry,
I am not able to understand the objective of a example. on.once is a method in dojo, used to listen to an event only once. it would be similar to code below.
var handle = on(map, "click", function(evt){
...
handle.remove();
}
It does not matter, which event. you can use on.once on any event, which you would like to listen just once.
Thanks. But, it is not always that simple... I want my code to fire only once. I have a couple callbacks when the event occurs. So... I need to wait until the callbacks are finished or, I was thinking, use the nifty on.once dojo functionality. I'm still not clear how to invoke it's magic.
None of the following works:
on.once(...);
on(...).once();
handle.once();
Jerry,
I use dojo on.once quit often in code.
on.once(map, "update-end", function(){
// will only fire once...
});
This works as long as the dojo.on module is called first, like so:
require(["dojo/on"], function(on) {
on.once(map, "update-end", function(){ // will only fire once... });
});
Thanks for this great tip!
I see. Pretty simple. Thanks!