question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

once event handler called twice

See original GitHub issue

Under some circumstances, an event handler set up with once can still be called twice.

See this example: http://playground-leaflet.rhcloud.com/vuv/edit?html,js,output

When the flyTo animation starts, pan the map with the mouse, and watch the log output: the moveend handler, set up with once is actually called twice.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jasonoverlandcommented, Apr 6, 2017

Nevermind my previous comment, I was encountering something entirely different. Angular-leaflet-directive clones the map layer and the handler was being removed from the original layer, not the clone.

0reactions
johnd0ecommented, Nov 6, 2021
describe('Events', function () {
	// ...
	describe('#once', function () {
		// ...
		it('do not stuck in loop when the event is fired again in handler', function () { // #3979 #5376
			var obj = new L.Evented();
			obj.once('test', function () {
				this.fire('test');
			});
			obj.fire('test');
		});
		// ...
	});
	// ...
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom Event handler is getting called twice? - Stack Overflow
The code snippet is very strange, hard to imagine why you'd subscribe the event after calling the method. It should never fire. Post...
Read more >
Event method called twice - MSDN - Microsoft
The event handler reports how it was changed to the screen. The problem is that it gives me the report twice. My guess...
Read more >
Event Handler called twice with the same event - Google Groups
After executing the test scenario, Axon will recreate the aggregate another time, this time based only on events, to verify that the state...
Read more >
Javascript Event Handler is firing twice - Elixir Forum
Have you checked if you run the code more than once? Maybe you have added two event listeners. yreuvekamp ...
Read more >
Event is fired twice in code (once in animation) - Spine
Typically you don't want to clear an event listener list you are registering to (this would then only support a single listener), instead...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found