<commit_before>var WinJS = require('winjs'),
  ioc = require('../ioc'),
  mixins = require('../helper/mixins'),
  winjsHelper = require('../helper/winjs');

var _constructor = function(element, options) {
  var that = this;
  this._viewModel = options;
  this._super.apply(this, arguments);
};

var instanceMembers = {
  update: function() {
    var that = this;
    var appService = ioc.getService("application");
    appService.setImmediate(function() {
      winjsHelper.markForProcessing(that.getViewModel());
      WinJS.UI.processAll(that.element);
      WinJS.Binding.processAll(that.element, that.getViewModel());
      WinJS.Resources.processAll(that.element);
    });
  },

  _onLoadingStateChanged: function() {
    if (this.getViewModel().getLoadingState() == "loaded") {
      this.update();
    }
  },

  getData: function() {
    if (this._viewModel)
      return this._viewModel.data;
    return null;
  },

  render: function(element, options, loadResult) {
    return this._super.prototype.render.apply(this, arguments);
  },

  init: function(element, options) {
    this.addManagedEventListener(this.getViewModel(), "loadingState", this._onLoadingStateChanged);
    return this._super.prototype.init.apply(this, arguments);
  },

  dispose: function() {
    var result = this._super.prototype.dispose.apply(this, arguments);
    this.removeAllManagedEventListeners();
    if (this.element)
      WinJS.Utilities.disposeSubTree(this.element);
    this._viewModel = null;

    return result;
  },

  processed: function(element, options) {
    var that = this;
    return new WinJS.Promise(function(complete, error, progress) {
      if (that._viewModel.getLoadingState() == "loading") {
        var callbackDelegate = function() {
          if (that._viewModel.getLoadingState() == "loaded") {
            that._viewModel.removeEventListener("loadingState", callbackDelegate);
            return complete();
          }
        };
        that._viewModel.addEventListener("loadingState", callbackDelegate);
      } else {
        return complete();
      }
    }).then(function() {
      that._onLoadingStateChanged();
    });
  },<commit_msg>BugFixes for view lifecycle for some architecture types<commit_after>var WinJS = require('winjs'),
  ioc = require('../ioc'),
  mixins = require('../helper/mixins'),
  winjsHelper = require('../helper/winjs');

var _constructor = function(element, options) {
  var that = this;
  this._viewModel = options;
  this._super.apply(this, arguments);
};

var instanceMembers = {
  update: function() {
    var that = this;
    var appService = ioc.getService("application");
    winjsHelper.markForProcessing(that.getViewModel());
    return WinJS.UI.processAll(that.element).then(function() {
      return WinJS.Binding.processAll(that.element, that.getViewModel()).then(function() {
        return WinJS.Resources.processAll(that.element);
      });
    });
  },

  _onLoadingStateChanged: function() {
    if (this.getViewModel().getLoadingState() == "loaded") {
      return this.update();
    }
    return WinJS.Promise.as();
  },

  getData: function() {
    if (this._viewModel)
      return this._viewModel.data;
    return null;
  },

  render: function(element, options, loadResult) {
    return this._super.prototype.render.apply(this, arguments);
  },

  init: function(element, options) {
    this.addManagedEventListener(this.getViewModel(), "loadingState", this._onLoadingStateChanged);
    return this._super.prototype.init.apply(this, arguments);
  },

  dispose: function() {
    var result = this._super.prototype.dispose.apply(this, arguments);
    this.removeAllManagedEventListeners();
    if (this.element)
      WinJS.Utilities.disposeSubTree(this.element);
    this._viewModel = null;

    return result;
  },

  processed: function(element, options) {
    var that = this;
    return new WinJS.Promise(function(complete, error, progress) {
      if (that._viewModel.getLoadingState() == "loading") {
        var callbackDelegate = function() {
          if (that._viewModel.getLoadingState() == "loaded") {
            that._viewModel.removeEventListener("loadingState", callbackDelegate);
            return complete();
          }
        };
        that._viewModel.addEventListener("loadingState", callbackDelegate);
      } else {
        return complete();
      }
    }).then(function() {
      return that._onLoadingStateChanged();
    });
  },
{'fraction_non_alphanumeric': 0.14053688247236634, 'fraction_numerical': 0.0, 'mean_word_length': 3.368472906403941, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7010944', 'n_tokens_mistral': 1280, 'n_tokens_neox': 1262, 'n_words': 235}