I'm currently new to the Gutenberg block development. I was wondering if there is a way to detect when the user clicks the publish/update button?

Reason for this is that i need to call a custom function right after the button click.