{"action":"created","issue":{"url":"https://api.github.com/repos/realm/realm-js/issues/496","repository_url":"https://api.github.com/repos/realm/realm-js","labels_url":"https://api.github.com/repos/realm/realm-js/issues/496/labels{/name}","comments_url":"https://api.github.com/repos/realm/realm-js/issues/496/comments","events_url":"https://api.github.com/repos/realm/realm-js/issues/496/events","html_url":"https://github.com/realm/realm-js/issues/496","id":161091694,"number":496,"title":"Specific `removeListener` not working.","user":{"login":"joshuapinter","id":180819,"avatar_url":"https://avatars.githubusercontent.com/u/180819?v=3","gravatar_id":"","url":"https://api.github.com/users/joshuapinter","html_url":"https://github.com/joshuapinter","followers_url":"https://api.github.com/users/joshuapinter/followers","following_url":"https://api.github.com/users/joshuapinter/following{/other_user}","gists_url":"https://api.github.com/users/joshuapinter/gists{/gist_id}","starred_url":"https://api.github.com/users/joshuapinter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshuapinter/subscriptions","organizations_url":"https://api.github.com/users/joshuapinter/orgs","repos_url":"https://api.github.com/users/joshuapinter/repos","events_url":"https://api.github.com/users/joshuapinter/events{/privacy}","received_events_url":"https://api.github.com/users/joshuapinter/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-06-19T20:50:44Z","updated_at":"2016-06-19T20:57:02Z","closed_at":"2016-06-19T20:57:01Z","body":"With the following `addListener` and `removeListener`, the listener remains active (i.e. doesn't get removed):\r\n\r\n```js\r\nRealm.addListener('change', this.realmChanged.bind(this));\r\n\r\nRealm.removeListener('change', this.realmChanged.bind(this));\r\n\r\n// A change to Realm will still trigger a call to realmChanged().\r\n```\r\n\r\nAm I using this correctly?\r\n\r\nThanks!\r\n\r\nJosh"},"comment":{"url":"https://api.github.com/repos/realm/realm-js/issues/comments/227019848","html_url":"https://github.com/realm/realm-js/issues/496#issuecomment-227019848","issue_url":"https://api.github.com/repos/realm/realm-js/issues/496","id":227019848,"user":{"login":"joshuapinter","id":180819,"avatar_url":"https://avatars.githubusercontent.com/u/180819?v=3","gravatar_id":"","url":"https://api.github.com/users/joshuapinter","html_url":"https://github.com/joshuapinter","followers_url":"https://api.github.com/users/joshuapinter/followers","following_url":"https://api.github.com/users/joshuapinter/following{/other_user}","gists_url":"https://api.github.com/users/joshuapinter/gists{/gist_id}","starred_url":"https://api.github.com/users/joshuapinter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshuapinter/subscriptions","organizations_url":"https://api.github.com/users/joshuapinter/orgs","repos_url":"https://api.github.com/users/joshuapinter/repos","events_url":"https://api.github.com/users/joshuapinter/events{/privacy}","received_events_url":"https://api.github.com/users/joshuapinter/received_events","type":"User","site_admin":false},"created_at":"2016-06-19T20:57:01Z","updated_at":"2016-06-19T20:57:01Z","body":"Okay, I figured the `.bind(this)` was causing issues so I was able to get the following to work just fine: \r\n\r\n```js\r\nthis.realmChanged = this.realmChanged.bind(this);\r\n\r\nRealm.addListener('change', this.realmChanged);\r\n\r\nRealm.removeListener('change', this.realmChanged);\r\n```\r\n\r\nI'm not a JS expert so was an obvious solution?\r\n\r\nAlso, it would be useful to put an example of `removeListener` in your non-API docs so others don't accidentally fall into a similar trap.\r\n\r\nThanks!"}}
{"actor":{"display_login":"joshuapinter"}}