{"action":"created","issue":{"url":"https://api.github.com/repos/pyblish/pyblish-base/issues/293","repository_url":"https://api.github.com/repos/pyblish/pyblish-base","labels_url":"https://api.github.com/repos/pyblish/pyblish-base/issues/293/labels{/name}","comments_url":"https://api.github.com/repos/pyblish/pyblish-base/issues/293/comments","events_url":"https://api.github.com/repos/pyblish/pyblish-base/issues/293/events","html_url":"https://github.com/pyblish/pyblish-base/issues/293","id":170903207,"number":293,"title":"Rename Callback to Handler","user":{"login":"mottosso","id":2152766,"avatar_url":"https://avatars.githubusercontent.com/u/2152766?v=3","gravatar_id":"","url":"https://api.github.com/users/mottosso","html_url":"https://github.com/mottosso","followers_url":"https://api.github.com/users/mottosso/followers","following_url":"https://api.github.com/users/mottosso/following{/other_user}","gists_url":"https://api.github.com/users/mottosso/gists{/gist_id}","starred_url":"https://api.github.com/users/mottosso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mottosso/subscriptions","organizations_url":"https://api.github.com/users/mottosso/orgs","repos_url":"https://api.github.com/users/mottosso/repos","events_url":"https://api.github.com/users/mottosso/events{/privacy}","received_events_url":"https://api.github.com/users/mottosso/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/pyblish/pyblish-base/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-08-12T15:56:23Z","updated_at":"2016-08-15T07:49:50Z","closed_at":null,"body":"### Goal\r\n\r\nThis is a purely cosmetic change, but I think also an important difference in mindset; **emit** signals and **handle** them.\r\n\r\n### Motivation\r\n\r\nA \"callback\" suggests running a function and having another function get \"called back\" once it's done. It's common in Javascript, which is asynchronous, for things like making a request and passing along a nameless function (i.e. lambda) that is to be run once it's done.\r\n\r\nThis isn't what is happening in Pyblish.\r\n\r\nInstead, callbacks are more closely related to signals and slots of Qt, and I think we should treat them that way.\r\n\r\n### Implementation\r\n\r\n`register_callback` should instead be` register_handler`. Alternatively, perhaps more succintly as `pyblish.api.on(\"someEvent\", my_handler)`\r\n\r\n```python\r\nfrom pyblish import api\r\n\r\ndef on_toggled(instance, before, after):\r\n  pass\r\n\r\n# Register\r\napi.on(\"instanceToggled\", on_toggled)\r\n\r\n# Deregister\r\ndel(on_toggled)\r\n\r\n# Get\r\napi.on(\"instanceToggled\")  # == (on_toggled,)\r\n```\r\n\r\n### Backwards Compatibility\r\n\r\nWe can maintain both for the time being, mark the current one as deprecated, and let it be. It doesn't change what they do or how they are emitted and should be relatively painless to transition to."},"comment":{"url":"https://api.github.com/repos/pyblish/pyblish-base/issues/comments/239746939","html_url":"https://github.com/pyblish/pyblish-base/issues/293#issuecomment-239746939","issue_url":"https://api.github.com/repos/pyblish/pyblish-base/issues/293","id":239746939,"user":{"login":"tokejepsen","id":1860085,"avatar_url":"https://avatars.githubusercontent.com/u/1860085?v=3","gravatar_id":"","url":"https://api.github.com/users/tokejepsen","html_url":"https://github.com/tokejepsen","followers_url":"https://api.github.com/users/tokejepsen/followers","following_url":"https://api.github.com/users/tokejepsen/following{/other_user}","gists_url":"https://api.github.com/users/tokejepsen/gists{/gist_id}","starred_url":"https://api.github.com/users/tokejepsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tokejepsen/subscriptions","organizations_url":"https://api.github.com/users/tokejepsen/orgs","repos_url":"https://api.github.com/users/tokejepsen/repos","events_url":"https://api.github.com/users/tokejepsen/events{/privacy}","received_events_url":"https://api.github.com/users/tokejepsen/received_events","type":"User","site_admin":false},"created_at":"2016-08-15T07:49:50Z","updated_at":"2016-08-15T07:49:50Z","body":"> A \"callback\" suggests running a function and having another function get \"called back\" once it's done. \r\n\r\nMakes sense, I'm in:)\r\n\r\n> pyblish.api.on(\"someEvent\", my_handler)\r\n\r\nIs this implemented elsewhere, or is this to follow more of a Qt signal/slots behaviour?\r\n\r\n> We can maintain both for the time being, mark the current one as deprecated, and let it be. It doesn't change what they do or how they are emitted and should be relatively painless to transition to.\r\n\r\nThis is becoming a higher and higher priority; https://github.com/pyblish/pyblish-qml/issues/165 to be able to keep up with deprecation :) Maybe we should be able to search our code base for deprecation? (sorry about derailing the topic)"}}
{"actor":{"display_login":"tokejepsen"}}