So I have a metabox which I want to trigger some Javascript when a post is saved (to refresh the page in this use case.)
In Classic Editor, this can be done via a simple redirect hooked to save_post
(with a high priority)
But since Gutenberg converts the saving process for existing metaboxes into individual AJAX calls now, it needs to be javascript, so how do I either:
Listen for an event where all the saving processes are complete and then trigger the javascript? If so what is this event called? Is there a reference to these events anywhere yet? OR
Trigger javascript inside the metabox saving AJAX process, which can then check the state of the parent page saving process before continuing?
wp.data
data storeswp.data.select('core/editor').isSavingPost()
... this kind of access is not documented anywhere I can see... and it seems also unreliable as it returnsfalse
after the post is first saved (before that it is undefined) whether the editor is still saving or not. facepalm