{"action":"closed","issue":{"url":"https://api.github.com/repos/jashkenas/backbone/issues/3599","labels_url":"https://api.github.com/repos/jashkenas/backbone/issues/3599/labels{/name}","comments_url":"https://api.github.com/repos/jashkenas/backbone/issues/3599/comments","events_url":"https://api.github.com/repos/jashkenas/backbone/issues/3599/events","html_url":"https://github.com/jashkenas/backbone/issues/3599","id":73441365,"number":3599,"title":"Event handlers executed after stopListening is called","user":{"login":"bendulum","id":2833178,"avatar_url":"https://avatars.githubusercontent.com/u/2833178?v=3","gravatar_id":"","url":"https://api.github.com/users/bendulum","html_url":"https://github.com/bendulum","followers_url":"https://api.github.com/users/bendulum/followers","following_url":"https://api.github.com/users/bendulum/following{/other_user}","gists_url":"https://api.github.com/users/bendulum/gists{/gist_id}","starred_url":"https://api.github.com/users/bendulum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bendulum/subscriptions","organizations_url":"https://api.github.com/users/bendulum/orgs","repos_url":"https://api.github.com/users/bendulum/repos","events_url":"https://api.github.com/users/bendulum/events{/privacy}","received_events_url":"https://api.github.com/users/bendulum/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-05T21:46:56Z","updated_at":"2015-05-05T22:42:22Z","closed_at":"2015-05-05T22:42:22Z","body":"The issue i ran into might be more of an _unhandled case_ than an actual bug. Consider the following setup:\r\n\r\n* There are 3 views, A, B & C\r\n* Both B & C listen to the same event triggered by A\r\n* In _some_ cases B destroys (remove / stop listening) C when the event is triggered\r\n* The event handler in C is still executed even if C was already destroyed by B\r\n\r\n[Here is a jsfiddle](https://jsfiddle.net/jtk19x4n/2/)\r\n\r\nI'm aware that it might not be ideal architecturally to have B destroy C, and rather have C destroy itself, but in my use case that is unavoidable.\r\nAlso, I can not guarantee in which order B and C are bound to A in my use case.\r\n\r\nThe point is that the expected behaviour of `stopListening` is that after calling it, event handlers will not be executed anymore.\r\n\r\nI am assuming backbone does some internal caching of the callback functions, and once the event fires, does not check anymore if the callbacks have been unbound in the interim...\r\n\r\nIs this a bug, intended behavior or how am I supposed to handle this case?"}}