I would like to have some kind of builtin method that takes care of object descruction so I don't have to deal with it manually when an object goes out of scope:
class Foo {
private var session;
// More code here
// and somewhere session.start() is called
function DESTROY() {
if (self.session != null) {
self.session.stop();
self.session.discard();
}
// More cleanup here
}
}
Reference thread: https://forums.garmin.com/developer/connect-iq/f/discussion/301049/destroying-an-object-and-doing-some-cleanup