Acknowledged

RFC: Object destruction method for automatically cleaning up what you made


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

Parents
  • I would really like to have this. In case you use timers in a layer and you pop a view the timers of your object stays alive. Causing an app crash before you exit your view.

    This would otherwise require extreme house keeping to kill the view with all the layers and such, which requires in depth knowledge of otherwise black boxes that most classes/objects in MonkeyC are because the implementation details are hidden behind the private/protected vars and methods.

Comment
  • I would really like to have this. In case you use timers in a layer and you pop a view the timers of your object stays alive. Causing an app crash before you exit your view.

    This would otherwise require extreme house keeping to kill the view with all the layers and such, which requires in depth knowledge of otherwise black boxes that most classes/objects in MonkeyC are because the implementation details are hidden behind the private/protected vars and methods.

Children
No Data