{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/react-native/issues/6493","repository_url":"https://api.github.com/repos/facebook/react-native","labels_url":"https://api.github.com/repos/facebook/react-native/issues/6493/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react-native/issues/6493/comments","events_url":"https://api.github.com/repos/facebook/react-native/issues/6493/events","html_url":"https://github.com/facebook/react-native/issues/6493","id":141429715,"number":6493,"title":"Framework inconsistency: removeEventListener() vs remove()","user":{"login":"lprhodes","id":162989,"avatar_url":"https://avatars.githubusercontent.com/u/162989?v=3","gravatar_id":"","url":"https://api.github.com/users/lprhodes","html_url":"https://github.com/lprhodes","followers_url":"https://api.github.com/users/lprhodes/followers","following_url":"https://api.github.com/users/lprhodes/following{/other_user}","gists_url":"https://api.github.com/users/lprhodes/gists{/gist_id}","starred_url":"https://api.github.com/users/lprhodes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lprhodes/subscriptions","organizations_url":"https://api.github.com/users/lprhodes/orgs","repos_url":"https://api.github.com/users/lprhodes/repos","events_url":"https://api.github.com/users/lprhodes/events{/privacy}","received_events_url":"https://api.github.com/users/lprhodes/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/facebook/react-native/labels/Contains%20Potential%20Question%20Keywords","name":"Contains Potential Question Keywords","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-03-16T23:18:21Z","updated_at":"2016-03-18T00:17:32Z","closed_at":null,"body":"It'd be great for the removal of listeners/observers to work in a consistent\r\n\r\nAt the moment there's two ways that work differently depending on which class is being used\r\n\r\n**DeviceEventEmitter**\r\n```\r\nthis.tabWillBlurObserver = DeviceEventEmitter.addListener('tabwillblur', this.tabWillBlur)\r\nthis.tabwillBlurObserver.remove()\r\n```\r\n\r\n**AppStateIOS**\r\n```\r\nAppStateIOS.addEventListener('change', this.handleAppStateChange)\r\nAppStateIOS.removeEventListener('change', this.handleAppStateChange)\r\n```\r\nIt feels more natural (from a learning point of view) to be able to remove something in the same way you added it. It also means there's less class vars which can make the code and IDE autocomplete feel cleaner.\r\n\r\ni.e. `DeviceEventEmitter.removeListener('tabwillblur', this.tabWillBlur)`\r\n\r\nThough I can also see the benefits of going the other way:\r\n\r\n`this.appStateObserver.remove()`\r\n\r\nThoughts?"},"comment":{"url":"https://api.github.com/repos/facebook/react-native/issues/comments/198141913","html_url":"https://github.com/facebook/react-native/issues/6493#issuecomment-198141913","issue_url":"https://api.github.com/repos/facebook/react-native/issues/6493","id":198141913,"user":{"login":"vjeux","id":197597,"avatar_url":"https://avatars.githubusercontent.com/u/197597?v=3","gravatar_id":"","url":"https://api.github.com/users/vjeux","html_url":"https://github.com/vjeux","followers_url":"https://api.github.com/users/vjeux/followers","following_url":"https://api.github.com/users/vjeux/following{/other_user}","gists_url":"https://api.github.com/users/vjeux/gists{/gist_id}","starred_url":"https://api.github.com/users/vjeux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vjeux/subscriptions","organizations_url":"https://api.github.com/users/vjeux/orgs","repos_url":"https://api.github.com/users/vjeux/repos","events_url":"https://api.github.com/users/vjeux/events{/privacy}","received_events_url":"https://api.github.com/users/vjeux/received_events","type":"User","site_admin":false},"created_at":"2016-03-18T00:17:32Z","updated_at":"2016-03-18T00:17:32Z","body":"For context, we had like 5 different implementations of subscriptions internally and couldn't decide which one to pick so we went to the web like which, while probably the worse from a design standpoint had the merit of working for all use cases. I'd love to do another pass at it at some point as the api is really bad.\r\n\r\nThe big thing we tried to do was to tie it to the component lifecycle, such that we couldn't accidentally leak it when forgetting to remove the subscription."}}