-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extensibility: Convert all filters for components to behave like HOCs #3827
Changes from all commits
bf62d31
befeb75
d564276
81d56ad
eedd1ad
0ffd9ef
7bba1db
a46d71a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { createHooks } from '@wordpress/hooks'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
|
@@ -11,29 +6,7 @@ import customClassName from './custom-class-name'; | |
import generatedClassName from './generated-class-name'; | ||
import matchers from './matchers'; | ||
|
||
const hooks = createHooks(); | ||
|
||
const { | ||
addFilter, | ||
removeFilter, | ||
removeAllFilters, | ||
applyFilters, | ||
doingFilter, | ||
didFilter, | ||
hasFilter, | ||
} = hooks; | ||
|
||
export { | ||
addFilter, | ||
removeFilter, | ||
removeAllFilters, | ||
applyFilters, | ||
doingFilter, | ||
didFilter, | ||
hasFilter, | ||
}; | ||
|
||
anchor( hooks ); | ||
customClassName( hooks ); | ||
generatedClassName( hooks ); | ||
matchers( hooks ); | ||
anchor(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor: Do we need to export these as functions anymore, or can they just call to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might not play well with unit tests. Need to verify. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In theory, we could export individual functions and apply filters when importing. I will open a follow-up so we could discuss it individually. |
||
customClassName(); | ||
generatedClassName(); | ||
matchers(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have strong opposition, but noting that there's a few implied conventions being introduced here:
/
?core/
but alsocore/custom-class-name/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slash is not allowed for hook names... we need another patch if we want to change that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can revisit namespaces, too. I’m fine with having only 2 first parts or open to other ideas.