Document open/close events

Is there any way to subscribe to events raised specifically on GH_Document open/close? GH_Canvas.DocumentChanged is useful, but it doesn’t tell me what happened to the old document, or where the new document came from. I have a singleton class tracking components that I’d like to clean up when a document is closed.

Found what I need: Grasshopper.Instances.DocumentServer.DocumentRemoved

There is no bottlenecking for events of all GH_Documents, but once you have a specific GH_Document you can subscribe to its events. Specifically GH_Document.ContextChanged may interest you.

Aha. That’s good too. Thanks!