Last active
May 24, 2022 08:17
-
-
Save firestar300/d145a55145965606f523498aaef937c2 to your computer and use it in GitHub Desktop.
Check if WordPress Gutenberg Block Editor is ready
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { select, subscribe } = wp.data; | |
const closeListener = subscribe( () => { | |
const isReady = select( 'core/editor' ).__unstableIsEditorReady(); | |
if ( ! isReady ) { | |
// Editor not ready. | |
return; | |
} | |
// Close the listener as soon as we know we are ready to avoid an infinite loop. | |
closeListener(); | |
// Your code is placed after this comment, once the editor is ready. | |
alert( 'is ready' ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment