Our durandal application has many modular UI components (all created using AMD constructor based viewmodels) and I would like to begin adding pub/sub communications. I need to determine the best way to ensure that subscriptions are 'cleaned up' properly.
When/how should these subscriptions be cleaned up?
The deactivate
event seems to be sufficient for a select few viewmodels, but what about the rest? I don't see a particular mechanism which would allow a viewmodel to reliably 'clean up' after itself.
Before I go implementing some sort of disposable pattern, is there some obvious approach I'm missing here?
Followup question: Is there anything to be done other than calling subscription.off() to properly clean up?