{"action":"created","comment":{"url":"https://api.github.com/repos/WordPress/packages/pulls/comments/144295444","pull_request_review_id":68931925,"id":144295444,"diff_hunk":"@@ -7,34 +6,30 @@ import createCurrentHook from './createCurrentHook';\n import createDoingHook from './createDoingHook';\n import createDidHook from './createDidHook';\n \n-// Add action/filter functions.\n-export const addAction = createAddHook( HOOKS.actions );\n-export const addFilter = createAddHook( HOOKS.filters );\n \n-// Remove action/filter functions.\n-export const removeAction = createRemoveHook( HOOKS.actions );\n-export const removeFilter = createRemoveHook( HOOKS.filters );\n-\n-// Has action/filter functions.\n-export const hasAction = createHasHook( HOOKS.actions );\n-export const hasFilter = createHasHook( HOOKS.filters );\n-\n-// Remove all actions/filters functions.\n-export const removeAllActions = createRemoveHook( HOOKS.actions, true );\n-export const removeAllFilters = createRemoveHook( HOOKS.filters, true );\n-\n-// Do action/apply filters functions.\n-export const doAction     = createRunHook( HOOKS.actions );\n-export const applyFilters = createRunHook( HOOKS.filters, true );\n-\n-// Current action/filter functions.\n-export const currentAction = createCurrentHook( HOOKS.actions );\n-export const currentFilter = createCurrentHook( HOOKS.filters );\n-\n-// Doing action/filter: true while a hook is being run.\n-export const doingAction = createDoingHook( HOOKS.actions );\n-export const doingFilter = createDoingHook( HOOKS.filters );\n-\n-// Did action/filter functions.\n-export const didAction = createDidHook( HOOKS.actions );\n-export const didFilter = createDidHook( HOOKS.filters );\n+export const createHooks = () => {","path":"packages/hooks/src/index.js","position":null,"original_position":40,"commit_id":"5a6a91887c2a98a0f1fcb9a9ca1477ef0093c0d2","original_commit_id":"031fdfddb6484329c6d884edd8440de69a256e58","user":{"login":"adamsilverstein","id":2676022,"avatar_url":"https://avatars0.githubusercontent.com/u/2676022?v=4","gravatar_id":"","url":"https://api.github.com/users/adamsilverstein","html_url":"https://github.com/adamsilverstein","followers_url":"https://api.github.com/users/adamsilverstein/followers","following_url":"https://api.github.com/users/adamsilverstein/following{/other_user}","gists_url":"https://api.github.com/users/adamsilverstein/gists{/gist_id}","starred_url":"https://api.github.com/users/adamsilverstein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamsilverstein/subscriptions","organizations_url":"https://api.github.com/users/adamsilverstein/orgs","repos_url":"https://api.github.com/users/adamsilverstein/repos","events_url":"https://api.github.com/users/adamsilverstein/events{/privacy}","received_events_url":"https://api.github.com/users/adamsilverstein/received_events","type":"User","site_admin":false},"body":"updated in https://github.com/WordPress/packages/pull/40/commits/5a6a91887c2a98a0f1fcb9a9ca1477ef0093c0d2","created_at":"2017-10-12T13:55:07Z","updated_at":"2017-10-12T13:55:07Z","html_url":"https://github.com/WordPress/packages/pull/40#discussion_r144295444","pull_request_url":"https://api.github.com/repos/WordPress/packages/pulls/40","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/WordPress/packages/pulls/comments/144295444"},"html":{"href":"https://github.com/WordPress/packages/pull/40#discussion_r144295444"},"pull_request":{"href":"https://api.github.com/repos/WordPress/packages/pulls/40"}},"in_reply_to_id":143460171},"pull_request":{"url":"https://api.github.com/repos/WordPress/packages/pulls/40","id":143290830,"html_url":"https://github.com/WordPress/packages/pull/40","diff_url":"https://github.com/WordPress/packages/pull/40.diff","patch_url":"https://github.com/WordPress/packages/pull/40.patch","issue_url":"https://api.github.com/repos/WordPress/packages/issues/40","number":40,"state":"open","locked":false,"title":"Add Hooks to objects via composition or as a mixin","user":{"login":"adamsilverstein","id":2676022,"avatar_url":"https://avatars0.githubusercontent.com/u/2676022?v=4","gravatar_id":"","url":"https://api.github.com/users/adamsilverstein","html_url":"https://github.com/adamsilverstein","followers_url":"https://api.github.com/users/adamsilverstein/followers","following_url":"https://api.github.com/users/adamsilverstein/following{/other_user}","gists_url":"https://api.github.com/users/adamsilverstein/gists{/gist_id}","starred_url":"https://api.github.com/users/adamsilverstein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamsilverstein/subscriptions","organizations_url":"https://api.github.com/users/adamsilverstein/orgs","repos_url":"https://api.github.com/users/adamsilverstein/repos","events_url":"https://api.github.com/users/adamsilverstein/events{/privacy}","received_events_url":"https://api.github.com/users/adamsilverstein/received_events","type":"User","site_admin":false},"body":"This PR is an experiment and seeks to encapsulate logic on a per object basis and change hooks from a global event handler to a mixin added to objects via composition.\r\n\r\nHooks can be added to an object via composition:\r\n\r\n`myObject.hooks = new Hooks()`\r\n\r\nAPI functions can then be called on the object: `myObject.hooks.addAction()`,  `myObject.hooks.applyFilters()`,etc.\r\n\r\nThis removes the requirement for complex namespaces when adding hooks, we only need a functionName to ensure we can always remove a hook. As @westonruter pointed out in [his comment on the trac ticket\r\n](https://core.trac.wordpress.org/ticket/21170#comment:180) this offers several potential advantages. we could add hooks in core at any level we felt appropriate, for example `wp.media.hooks` or - if we decided it was appropriate - right at `wp.hooks`. \r\n\r\nAre we loosing anything other than potentially reduced file sizes by switching this from a global to a per object approach?\r\n","created_at":"2017-09-27T03:30:46Z","updated_at":"2017-10-12T13:55:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"69689a993247ab2039b8c25fe7a038d871ac1aeb","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/WordPress/packages/pulls/40/commits","review_comments_url":"https://api.github.com/repos/WordPress/packages/pulls/40/comments","review_comment_url":"https://api.github.com/repos/WordPress/packages/pulls/comments{/number}","comments_url":"https://api.github.com/repos/WordPress/packages/issues/40/comments","statuses_url":"https://api.github.com/repos/WordPress/packages/statuses/5a6a91887c2a98a0f1fcb9a9ca1477ef0093c0d2","head":{"label":"WordPress:add-hooks-via-composition","ref":"add-hooks-via-composition","sha":"5a6a91887c2a98a0f1fcb9a9ca1477ef0093c0d2","user":{"login":"WordPress","id":276006,"avatar_url":"https://avatars0.githubusercontent.com/u/276006?v=4","gravatar_id":"","url":"https://api.github.com/users/WordPress","html_url":"https://github.com/WordPress","followers_url":"https://api.github.com/users/WordPress/followers","following_url":"https://api.github.com/users/WordPress/following{/other_user}","gists_url":"https://api.github.com/users/WordPress/gists{/gist_id}","starred_url":"https://api.github.com/users/WordPress/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WordPress/subscriptions","organizations_url":"https://api.github.com/users/WordPress/orgs","repos_url":"https://api.github.com/users/WordPress/repos","events_url":"https://api.github.com/users/WordPress/events{/privacy}","received_events_url":"https://api.github.com/users/WordPress/received_events","type":"Organization","site_admin":false},"repo":{"id":95565400,"name":"packages","full_name":"WordPress/packages","owner":{"login":"WordPress","id":276006,"avatar_url":"https://avatars0.githubusercontent.com/u/276006?v=4","gravatar_id":"","url":"https://api.github.com/users/WordPress","html_url":"https://github.com/WordPress","followers_url":"https://api.github.com/users/WordPress/followers","following_url":"https://api.github.com/users/WordPress/following{/other_user}","gists_url":"https://api.github.com/users/WordPress/gists{/gist_id}","starred_url":"https://api.github.com/users/WordPress/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WordPress/subscriptions","organizations_url":"https://api.github.com/users/WordPress/orgs","repos_url":"https://api.github.com/users/WordPress/repos","events_url":"https://api.github.com/users/WordPress/events{/privacy}","received_events_url":"https://api.github.com/users/WordPress/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/WordPress/packages","description":"Collection of JS modules and tools for WordPress development","fork":false,"url":"https://api.github.com/repos/WordPress/packages","forks_url":"https://api.github.com/repos/WordPress/packages/forks","keys_url":"https://api.github.com/repos/WordPress/packages/keys{/key_id}","collaborators_url":"https://api.github.com/repos/WordPress/packages/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/WordPress/packages/teams","hooks_url":"https://api.github.com/repos/WordPress/packages/hooks","issue_events_url":"https://api.github.com/repos/WordPress/packages/issues/events{/number}","events_url":"https://api.github.com/repos/WordPress/packages/events","assignees_url":"https://api.github.com/repos/WordPress/packages/assignees{/user}","branches_url":"https://api.github.com/repos/WordPress/packages/branches{/branch}","tags_url":"https://api.github.com/repos/WordPress/packages/tags","blobs_url":"https://api.github.com/repos/WordPress/packages/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/WordPress/packages/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/WordPress/packages/git/refs{/sha}","trees_url":"https://api.github.com/repos/WordPress/packages/git/trees{/sha}","statuses_url":"https://api.github.com/repos/WordPress/packages/statuses/{sha}","languages_url":"https://api.github.com/repos/WordPress/packages/languages","stargazers_url":"https://api.github.com/repos/WordPress/packages/stargazers","contributors_url":"https://api.github.com/repos/WordPress/packages/contributors","subscribers_url":"https://api.github.com/repos/WordPress/packages/subscribers","subscription_url":"https://api.github.com/repos/WordPress/packages/subscription","commits_url":"https://api.github.com/repos/WordPress/packages/commits{/sha}","git_commits_url":"https://api.github.com/repos/WordPress/packages/git/commits{/sha}","comments_url":"https://api.github.com/repos/WordPress/packages/comments{/number}","issue_comment_url":"https://api.github.com/repos/WordPress/packages/issues/comments{/number}","contents_url":"https://api.github.com/repos/WordPress/packages/contents/{+path}","compare_url":"https://api.github.com/repos/WordPress/packages/compare/{base}...{head}","merges_url":"https://api.github.com/repos/WordPress/packages/merges","archive_url":"https://api.github.com/repos/WordPress/packages/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/WordPress/packages/downloads","issues_url":"https://api.github.com/repos/WordPress/packages/issues{/number}","pulls_url":"https://api.github.com/repos/WordPress/packages/pulls{/number}","milestones_url":"https://api.github.com/repos/WordPress/packages/milestones{/number}","notifications_url":"https://api.github.com/repos/WordPress/packages/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/WordPress/packages/labels{/name}","releases_url":"https://api.github.com/repos/WordPress/packages/releases{/id}","deployments_url":"https://api.github.com/repos/WordPress/packages/deployments","created_at":"2017-06-27T14:10:12Z","updated_at":"2017-10-08T16:35:40Z","pushed_at":"2017-10-12T13:51:18Z","git_url":"git://github.com/WordPress/packages.git","ssh_url":"git@github.com:WordPress/packages.git","clone_url":"https://github.com/WordPress/packages.git","svn_url":"https://github.com/WordPress/packages","homepage":null,"size":283,"stargazers_count":23,"watchers_count":23,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":12,"forks":4,"open_issues":12,"watchers":23,"default_branch":"master"}},"base":{"label":"WordPress:master","ref":"master","sha":"74212b91d68a240d1d58e3116dd89a14d7c1892d","user":{"login":"WordPress","id":276006,"avatar_url":"https://avatars0.githubusercontent.com/u/276006?v=4","gravatar_id":"","url":"https://api.github.com/users/WordPress","html_url":"https://github.com/WordPress","followers_url":"https://api.github.com/users/WordPress/followers","following_url":"https://api.github.com/users/WordPress/following{/other_user}","gists_url":"https://api.github.com/users/WordPress/gists{/gist_id}","starred_url":"https://api.github.com/users/WordPress/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WordPress/subscriptions","organizations_url":"https://api.github.com/users/WordPress/orgs","repos_url":"https://api.github.com/users/WordPress/repos","events_url":"https://api.github.com/users/WordPress/events{/privacy}","received_events_url":"https://api.github.com/users/WordPress/received_events","type":"Organization","site_admin":false},"repo":{"id":95565400,"name":"packages","full_name":"WordPress/packages","owner":{"login":"WordPress","id":276006,"avatar_url":"https://avatars0.githubusercontent.com/u/276006?v=4","gravatar_id":"","url":"https://api.github.com/users/WordPress","html_url":"https://github.com/WordPress","followers_url":"https://api.github.com/users/WordPress/followers","following_url":"https://api.github.com/users/WordPress/following{/other_user}","gists_url":"https://api.github.com/users/WordPress/gists{/gist_id}","starred_url":"https://api.github.com/users/WordPress/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WordPress/subscriptions","organizations_url":"https://api.github.com/users/WordPress/orgs","repos_url":"https://api.github.com/users/WordPress/repos","events_url":"https://api.github.com/users/WordPress/events{/privacy}","received_events_url":"https://api.github.com/users/WordPress/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/WordPress/packages","description":"Collection of JS modules and tools for WordPress development","fork":false,"url":"https://api.github.com/repos/WordPress/packages","forks_url":"https://api.github.com/repos/WordPress/packages/forks","keys_url":"https://api.github.com/repos/WordPress/packages/keys{/key_id}","collaborators_url":"https://api.github.com/repos/WordPress/packages/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/WordPress/packages/teams","hooks_url":"https://api.github.com/repos/WordPress/packages/hooks","issue_events_url":"https://api.github.com/repos/WordPress/packages/issues/events{/number}","events_url":"https://api.github.com/repos/WordPress/packages/events","assignees_url":"https://api.github.com/repos/WordPress/packages/assignees{/user}","branches_url":"https://api.github.com/repos/WordPress/packages/branches{/branch}","tags_url":"https://api.github.com/repos/WordPress/packages/tags","blobs_url":"https://api.github.com/repos/WordPress/packages/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/WordPress/packages/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/WordPress/packages/git/refs{/sha}","trees_url":"https://api.github.com/repos/WordPress/packages/git/trees{/sha}","statuses_url":"https://api.github.com/repos/WordPress/packages/statuses/{sha}","languages_url":"https://api.github.com/repos/WordPress/packages/languages","stargazers_url":"https://api.github.com/repos/WordPress/packages/stargazers","contributors_url":"https://api.github.com/repos/WordPress/packages/contributors","subscribers_url":"https://api.github.com/repos/WordPress/packages/subscribers","subscription_url":"https://api.github.com/repos/WordPress/packages/subscription","commits_url":"https://api.github.com/repos/WordPress/packages/commits{/sha}","git_commits_url":"https://api.github.com/repos/WordPress/packages/git/commits{/sha}","comments_url":"https://api.github.com/repos/WordPress/packages/comments{/number}","issue_comment_url":"https://api.github.com/repos/WordPress/packages/issues/comments{/number}","contents_url":"https://api.github.com/repos/WordPress/packages/contents/{+path}","compare_url":"https://api.github.com/repos/WordPress/packages/compare/{base}...{head}","merges_url":"https://api.github.com/repos/WordPress/packages/merges","archive_url":"https://api.github.com/repos/WordPress/packages/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/WordPress/packages/downloads","issues_url":"https://api.github.com/repos/WordPress/packages/issues{/number}","pulls_url":"https://api.github.com/repos/WordPress/packages/pulls{/number}","milestones_url":"https://api.github.com/repos/WordPress/packages/milestones{/number}","notifications_url":"https://api.github.com/repos/WordPress/packages/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/WordPress/packages/labels{/name}","releases_url":"https://api.github.com/repos/WordPress/packages/releases{/id}","deployments_url":"https://api.github.com/repos/WordPress/packages/deployments","created_at":"2017-06-27T14:10:12Z","updated_at":"2017-10-08T16:35:40Z","pushed_at":"2017-10-12T13:51:18Z","git_url":"git://github.com/WordPress/packages.git","ssh_url":"git@github.com:WordPress/packages.git","clone_url":"https://github.com/WordPress/packages.git","svn_url":"https://github.com/WordPress/packages","homepage":null,"size":283,"stargazers_count":23,"watchers_count":23,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":12,"forks":4,"open_issues":12,"watchers":23,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/WordPress/packages/pulls/40"},"html":{"href":"https://github.com/WordPress/packages/pull/40"},"issue":{"href":"https://api.github.com/repos/WordPress/packages/issues/40"},"comments":{"href":"https://api.github.com/repos/WordPress/packages/issues/40/comments"},"review_comments":{"href":"https://api.github.com/repos/WordPress/packages/pulls/40/comments"},"review_comment":{"href":"https://api.github.com/repos/WordPress/packages/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/WordPress/packages/pulls/40/commits"},"statuses":{"href":"https://api.github.com/repos/WordPress/packages/statuses/5a6a91887c2a98a0f1fcb9a9ca1477ef0093c0d2"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"adamsilverstein"}}