How to detect when node is deleted

Hi, my plugin is saving a list of node ids and their corresponding aspect ratios in my root node.

I want the plugin data in my root node to be updated whenever a node is deleted. Are there any events that are triggered whenever a node is deleted? If so, what event handler should I use to handle that?

Where would the deleteChange event be handled? I tried to handle it using figma.on() but it doesn’t work

There is no such thing as deleteChange:

All available events are listed above. I sent 3 links to the documentchange event so… that’s the one you should use. DocumentChange events have the following types (again, as shown in the links I sent):

Ok, I figured out that I have to handle the documentchange event using figma.on. Then, I need to extract out the array of documentchange objects from the event and check each object to see if they are of type “DELETE” like so:

I had a hard time understanding what you meant until I saw some code examples