{"action":"created","issue":{"url":"https://api.github.com/repos/paperjs/paper.js/issues/810","labels_url":"https://api.github.com/repos/paperjs/paper.js/issues/810/labels{/name}","comments_url":"https://api.github.com/repos/paperjs/paper.js/issues/810/comments","events_url":"https://api.github.com/repos/paperjs/paper.js/issues/810/events","html_url":"https://github.com/paperjs/paper.js/issues/810","id":113066751,"number":810,"title":"onFrame (the function) and view.on('frame', function) create separate handlers","user":{"login":"bmacnaughton","id":4171707,"avatar_url":"https://avatars.githubusercontent.com/u/4171707?v=3","gravatar_id":"","url":"https://api.github.com/users/bmacnaughton","html_url":"https://github.com/bmacnaughton","followers_url":"https://api.github.com/users/bmacnaughton/followers","following_url":"https://api.github.com/users/bmacnaughton/following{/other_user}","gists_url":"https://api.github.com/users/bmacnaughton/gists{/gist_id}","starred_url":"https://api.github.com/users/bmacnaughton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bmacnaughton/subscriptions","organizations_url":"https://api.github.com/users/bmacnaughton/orgs","repos_url":"https://api.github.com/users/bmacnaughton/repos","events_url":"https://api.github.com/users/bmacnaughton/events{/privacy}","received_events_url":"https://api.github.com/users/bmacnaughton/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-23T17:45:16Z","updated_at":"2015-10-23T17:54:28Z","closed_at":null,"body":"When I create a frame handler using the syntax `function onFrame(e) {...}` and also create a function using `view.on('frame', function(e) {...})` they both get called on the frame event.\r\n\r\nHere's a sketch demonstrating the issue - each of the two handlers draws different colored circles.\r\n\r\nhttp://sketch.paperjs.org/#S/vZPBTsMwDIZfxeplrTR1wLGIE4gb0iSQOFAOWequ0TK7StJVMO3dSdJuK0IIwYH0kMaO/3x24n1CYotJkTxu0MkmmSeSq7AuyYhKdRZu4PLiuiSJ5ND41U5hn1v1jvm20061+i1dsiKXG0EVb9Ms87tLqjuSTjFBZUR/q4zUmErWbDLYlwR+7ISB36mGKMIelsI1+ag5ioUxiBXjPD87hkyKcZ44rDO8wduA5cPC9MX5rCrXFHA12A9ZSYeQ3mIBrlEWZKSANTobM/WuScIzg9VsqMcx4FQXwp3PPAZKoTVWk5ox3Rt/LSmeijUVXWkhN1E2okgmyxpzzet0VrORCALqEB/3xMriVjnvjMY57A+fmSYQ/mhvQ6hZa+4VrcH1DCHcjlIjm7+zI+43mGuDSP+GGUJPhGeNHxjbzrR6ABgP+zumY9a+KuGBPvnfNFiDzfM8cGfxjnuaVu3cCBG6ro+SxzcWPt+QK4Ni04ZmsEnx8nr4AA=="},"comment":{"url":"https://api.github.com/repos/paperjs/paper.js/issues/comments/150646621","html_url":"https://github.com/paperjs/paper.js/issues/810#issuecomment-150646621","issue_url":"https://api.github.com/repos/paperjs/paper.js/issues/810","id":150646621,"user":{"login":"lehni","id":213275,"avatar_url":"https://avatars.githubusercontent.com/u/213275?v=3","gravatar_id":"","url":"https://api.github.com/users/lehni","html_url":"https://github.com/lehni","followers_url":"https://api.github.com/users/lehni/followers","following_url":"https://api.github.com/users/lehni/following{/other_user}","gists_url":"https://api.github.com/users/lehni/gists{/gist_id}","starred_url":"https://api.github.com/users/lehni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lehni/subscriptions","organizations_url":"https://api.github.com/users/lehni/orgs","repos_url":"https://api.github.com/users/lehni/repos","events_url":"https://api.github.com/users/lehni/events{/privacy}","received_events_url":"https://api.github.com/users/lehni/received_events","type":"User","site_admin":false},"created_at":"2015-10-23T17:54:28Z","updated_at":"2015-10-23T17:54:28Z","body":"It's not a bug that they both get called, that's intended behavior. If you call `view.on('frame')` twice with two functions it also installs them both, as it would be in almost any JS based event emitter class. The problem is that one of the events installed in this way doesn't seem to get called, but I understand now why, and I think it's a wont-fix:\r\n\r\nThe global `function onFrame() {}` is actually just a PaperScript convenience short-cut to `view.onFrame = function() {}`. If you have defined both, then the global one will replace the instance-based one at the end of the execution of the PaperScript code. This explains why manually triggering the event draws two green circles, while afterwards only black ones get drawn."}}