
var angular = require('angular');
require('../modules');
require('./sinoNetwork');

angular
   .module('commons.services.appInitStop')
   .run(run);

/** @ngInject */
function run($rootScope, sinoNetwork) {
  var stopAppInitNum = 1;
  
  $rootScope.$on('stopAppInit', function() {
    if (stopAppInitNum > 0) {
      sinoNetwork.stopAppInit();
      stopAppInitNum -= 1;
    }
  });
  
  $rootScope.$on('$stateChangeSuccess', function() {
    if (stopAppInitNum > 0) {
      sinoNetwork.stopAppInit();
      stopAppInitNum -= 1;
    }
  });
}
