FR: Async fetching prior to block registration #12232
Labels
[Feature] Block API
API that allows to express the block paradigm.
[Feature] Extensibility
The ability to extend blocks or the editing experience
[Status] Duplicate
Used to indicate that a current issue matches an existing one and can be closed
Is your feature request related to a problem? Please describe.
While working on Jetpack Gutenberg blocks and plugins, we've recently found a few instances where some sort of async fetching of resources prior to block registration would come in handy. Examples include:
wp-admin
, e.g. in Calypso. We have a Calypso-specific workaround (Gutenberg: Load Jetpack block translations in Calypso synchronously Automattic/wp-calypso#28304) that takes care of loading translation files prior to loading Gutenberg, but we were wondering if more native tooling might be in order here. (We can't simply load translations after the editor and rely on React re-rendering strings afterwards for things like block names and descriptions that we pass toregisterBlockType
).Describe the solution you'd like
A bit fuzzy, but maybe allow
registerBlockType()
(andregisterPlugin()
) to return a promise, and wait for that to be resolved?Describe alternatives you've considered
For 1. -- see the workaround mentioned there.
For 2. -- In
wp-admin
, we're usingwp_localize_script
to set a global variable to contain relevant information(None of which are particularly nice.)
/cc @sirreal @tyxla @simison @lezama @enejb
The text was updated successfully, but these errors were encountered: