Plugin data saving before "Save" button click


Imagine that your plugin creates some files on an abstract backend.
You click “add new file” and then you want to click “Save dashboard”. It would be great

  1. Get notification about saving process initiation and do saving which I need in my plugin
  2. Stop saving process if plugin failed to save something.

So I can sync plugin.json with actual state of all system. Can I achieve this anyhow?