Uploaded image for project: 'Moodle app'
  1. Moodle app
  2. MOBILE-1079

Implement an app "init process"

XMLWordPrintable

    • Hide

      Test 1

      1. Create a few app init processes (see below)
      2. Make sure some are delaying the initialisation by a few seconds
      3. Then add some actions on $mmApp.ready
      4. Confirm that the actions are delayed until the init are finished
      5. Confirm that the priority of the processes is respected

      Test 2

      1. Make sure that the following still works:
        • Session is restored, you're automatically logged in to the last site
        • If you log out you're not automatically logged in
        • Local notifications work
        • Push notifications work
        • Clicking on notifications brings you where you had to go
        • Uploading files on iOS

      Test 3

      1. Make sure that the following still works:
        • Addons below course names
        • Module addons
        • User addons

      Test 1 Helper

      angular.module('mm.core')
       
      .config(function($mmInitDelegateProvider) {
          $mmInitDelegateProvider.registerProcess('mmTest1', 'mmTest.test1', 0);
          $mmInitDelegateProvider.registerProcess('mmTest2', 'mmTest.test2');
          $mmInitDelegateProvider.registerProcess('mmTest3', 'mmTest.test3', 99);
          $mmInitDelegateProvider.registerProcess('mmTest4', 'mmTest.test4', 150, true);
          $mmInitDelegateProvider.registerProcess('mmTest5', 'mmTest.test5', 400);
          $mmInitDelegateProvider.registerProcess('mmTest6', 'mmTest.test6', 300);
      })
       
      .factory('mmTest', function($q, $timeout) {
          var self = {};
       
          self.test1 = function() {
              var q = $q.defer();
              $timeout(function() { console.log('Resolving test1', new Date().getTime()); q.resolve(); }, 1000);
              return q.promise;
          };
       
          self.test2 = function() {
              var q = $q.defer();
              $timeout(function() { console.log('Resolving test2', new Date().getTime()); q.resolve(); }, 1000);
              return q.promise;
          };
       
          self.test3 = function() {
              var q = $q.defer();
              $timeout(function() { console.log('Resolving test3', new Date().getTime()); q.resolve(); }, 1000);
              return q.promise;
          };
       
          self.test4 = function() {
              var q = $q.defer();
              $timeout(function() { console.log('Resolving test4', new Date().getTime()); q.resolve(); }, 1000);
              return q.promise;
          };
       
          self.test5 = function() {
              var q = $q.defer();
              $timeout(function() { console.log('Resolving test5', new Date().getTime()); q.resolve(); }, 1000);
              return q.promise;
          };
       
          self.test6 = function() {
              var q = $q.defer();
              $timeout(function() { console.log('Resolving test6', new Date().getTime()); q.resolve(); }, 1000);
              return q.promise;
          };
       
          return self;
      });
      

      Show
      Test 1 Create a few app init processes (see below) Make sure some are delaying the initialisation by a few seconds Then add some actions on $mmApp.ready Confirm that the actions are delayed until the init are finished Confirm that the priority of the processes is respected Test 2 Make sure that the following still works: Session is restored, you're automatically logged in to the last site If you log out you're not automatically logged in Local notifications work Push notifications work Clicking on notifications brings you where you had to go Uploading files on iOS Test 3 Make sure that the following still works: Addons below course names Module addons User addons Test 1 Helper angular.module('mm.core')   .config(function($mmInitDelegateProvider) { $mmInitDelegateProvider.registerProcess('mmTest1', 'mmTest.test1', 0); $mmInitDelegateProvider.registerProcess('mmTest2', 'mmTest.test2'); $mmInitDelegateProvider.registerProcess('mmTest3', 'mmTest.test3', 99); $mmInitDelegateProvider.registerProcess('mmTest4', 'mmTest.test4', 150, true); $mmInitDelegateProvider.registerProcess('mmTest5', 'mmTest.test5', 400); $mmInitDelegateProvider.registerProcess('mmTest6', 'mmTest.test6', 300); })   .factory('mmTest', function($q, $timeout) { var self = {};   self.test1 = function() { var q = $q.defer(); $timeout(function() { console.log('Resolving test1', new Date().getTime()); q.resolve(); }, 1000); return q.promise; };   self.test2 = function() { var q = $q.defer(); $timeout(function() { console.log('Resolving test2', new Date().getTime()); q.resolve(); }, 1000); return q.promise; };   self.test3 = function() { var q = $q.defer(); $timeout(function() { console.log('Resolving test3', new Date().getTime()); q.resolve(); }, 1000); return q.promise; };   self.test4 = function() { var q = $q.defer(); $timeout(function() { console.log('Resolving test4', new Date().getTime()); q.resolve(); }, 1000); return q.promise; };   self.test5 = function() { var q = $q.defer(); $timeout(function() { console.log('Resolving test5', new Date().getTime()); q.resolve(); }, 1000); return q.promise; };   self.test6 = function() { var q = $q.defer(); $timeout(function() { console.log('Resolving test6', new Date().getTime()); q.resolve(); }, 1000); return q.promise; };   return self; });
    • MOODLE_21_STABLE
    • MOODLE_21_STABLE

      As discussed on MOBILE-831, we need an app init process to be able to know the app is initialized. Fred comments about this:

      1. Creating a place where we can register init process
      2. Those init process need to return promises
      3. All those init processes need to be registered before the following:
      4. An event is triggered once all the init process have been resolved/rejected

      I believe we cannot limit the init processes to .config(), and .run() is pretty async so it's hard to predict when our 'checkInit' needs to be run. But for sure we need to register at least one init process before we call 'checkInit', and once checkInit is finished we need to go through the init processes to see if any new one was added. The init processes need to register a function which will return a promise, they should not call the promise straight. 'checkInit' will trigger an event resolving the promise of $mmApp.ready(), or $mmApp.initialised() or something.

            fred Frédéric Massart
            dpalou Dani Palou
            Dani Palou Dani Palou
            Juan Leyva Juan Leyva
            Juan Leyva Juan Leyva
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.