{"action":"opened","issue":{"url":"https://api.github.com/repos/ractivejs/ractive/issues/2034","labels_url":"https://api.github.com/repos/ractivejs/ractive/issues/2034/labels{/name}","comments_url":"https://api.github.com/repos/ractivejs/ractive/issues/2034/comments","events_url":"https://api.github.com/repos/ractivejs/ractive/issues/2034/events","html_url":"https://github.com/ractivejs/ractive/issues/2034","id":94587219,"number":2034,"title":"Lifecycle hook events should contain info about current instance","user":{"login":"Rich-Harris","id":1162160,"avatar_url":"https://avatars.githubusercontent.com/u/1162160?v=3","gravatar_id":"","url":"https://api.github.com/users/Rich-Harris","html_url":"https://github.com/Rich-Harris","followers_url":"https://api.github.com/users/Rich-Harris/followers","following_url":"https://api.github.com/users/Rich-Harris/following{/other_user}","gists_url":"https://api.github.com/users/Rich-Harris/gists{/gist_id}","starred_url":"https://api.github.com/users/Rich-Harris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rich-Harris/subscriptions","organizations_url":"https://api.github.com/users/Rich-Harris/orgs","repos_url":"https://api.github.com/users/Rich-Harris/repos","events_url":"https://api.github.com/users/Rich-Harris/events{/privacy}","received_events_url":"https://api.github.com/users/Rich-Harris/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ractivejs/ractive/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-12T17:58:37Z","updated_at":"2015-07-12T17:58:37Z","closed_at":null,"body":"My current problem: maintaining a lookup table of Ractive instances corresponding to nodes in a tree of arbitrary depth (an AST). The easiest way would be for the instance that contains the tree to listen for `Node.render` events bubbling up...\r\n\r\n```js\r\nlet lookup = {};\r\n\r\nthis.on({\r\n  'Node.render', event => {\r\n    const { instance } = event;\r\n    lookup[ instance.uid ] = instance;\r\n  },\r\n  'Node.unrender', event => {\r\n    const { instance } = event;\r\n    delete lookup[ instance.uid ];\r\n  }\r\n});\r\n```\r\n\r\n...but that doesn't work because the `render` hook doesn't generate an `event` object. (Demo: http://jsfiddle.net/z1ffp1ws/.) Easy enough to work around for the time being, but this'd be nice to add at some point in the future."}}