-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Idea for block registry. #336
Comments
One drawback of this approach for clients would be that it's no longer possible to register a block in a single function call. It looks like the proposed Given that, it's hard for me to see the advantages of pulling this operation out into two functions. |
Yup, definitely. I was thinking in the future there may come a point where two instances of the editor may need exist and will need to have different blockTypes registered to them. So for now we can probably close this out. It can be done then, if it is ever needed. |
Hi, just throwing out some ideas on the block registering API.
wp.blocks.registerBlock( slug, settings )
which returns the block and also adds the block as a key, value pair to the somewhat globalblocks
. This is a coupling that I do not think should be made. I would recommend the creation of a block to be handled in a functionblockType( slug, settings )
( or preferably just settings ). Then the registry of blocks can be another factory function that creates registries of blocks, which can have the methodregisterBlock( block )
on them.This will make testing a lot easier/cleaner and will also create a bit more flexibility in the code for unforeseen future needs.
The text was updated successfully, but these errors were encountered: