locked
Will attached listeners stay around when class using WinJS.Utilities.eventMixin is null'ed?

    Question

  • I have this scenario:
    WinJS.Utilities.eventMixin mixed class

    This class is used in my global app state binding like this:

    WinJS.Namespace.define("app", {
      state: WinJS.Binding.as(
        currentTaskEdit: null
      )
    });
    

    Somewhere in my program I have a listener attached like this:

    app.state.bind("currentTaskEdit", function(newEdit, oldEdit) {
      if (newEdit) {
        newEdit.addEventListener("saved", function() {
        });
        newEdit.addEventListener("canceled", function() {
        });
      }
    });
    

    That is triggered when app.state.currentTaskEdit = new TaskEdit().
    The question is what happens when some other part assigned null to the state variable like this:
    app.state.currentTaskEdit = null

    Does this clear up the references to my 2 listeners? Or do I have to remember the object I bind to and when this app.state.currentTaskEdit becomes null, to use my saved reference to remove my listeners from the old object instance?
    I know there technically no weak-references, which listeners should actually be, in JS, so thats why I ask.

    Saturday, August 16, 2014 11:27 PM

All replies

  • Since you are using HTML5/JS you can just reload the data as you would when you retrieved it in the first place. I'm assuming that's an AJAX call or similar. There is no "refresh page" command or anything like that.

    Or if you are working on Navigation App ( you have the Navigation.JS) 

    you may use : 

    WinJS.Navigation.navigate("your-page-name-here.html");
    Tuesday, August 19, 2014 7:41 AM
  • Thanks, but how does that relate to my question?
    Tuesday, August 19, 2014 8:38 AM