support for plugins where the init method doesn't return a Promise

This commit is contained in:
Hakim El Hattab 2019-03-14 14:52:59 +01:00
parent 5301a9ea03
commit 6410ed15aa
5 changed files with 17 additions and 20 deletions

View file

@ -539,29 +539,34 @@
var pluginsToInitialize = Object.keys( plugins ).length; var pluginsToInitialize = Object.keys( plugins ).length;
var afterPlugInitialized = function() {
if( --pluginsToInitialize === 0 ) {
loadAsyncDependencies();
}
};
for( var i in plugins ) { for( var i in plugins ) {
var plugin = plugins[i]; var plugin = plugins[i];
// If the plugin has an 'init' method, initialize and // If the plugin has an 'init' method, invoke it
// wait for the callback
if( typeof plugin.init === 'function' ) { if( typeof plugin.init === 'function' ) {
plugin.init().then( function() { var callback = plugin.init();
if( --pluginsToInitialize === 0 ) {
loadAsyncDependencies(); // If the plugin returned a Promise, wait for it
} if( callback && typeof callback.then === 'function' ) {
} ); callback.then( afterPlugInitialized );
}
else {
afterPlugInitialized();
}
} }
else { else {
pluginsToInitialize -= 1; afterPlugInitialized();
} }
} }
if( pluginsToInitialize === 0 ) {
loadAsyncDependencies();
}
} }
/** /**

View file

@ -97,8 +97,6 @@ c:[{cN:"comment",b:/\(\*/,e:/\*\)/},e.ASM,e.QSM,e.CNM,{b:/\{/,e:/\}/,i:/:/}]}});
} }
} ); } );
return Promise.resolve();
}, },
/** /**

View file

@ -84,8 +84,6 @@ var RevealMath = window.RevealMath || (function(){
} ); } );
return Promise.resolve();
} }
} }

View file

@ -168,8 +168,6 @@ var RevealNotes = (function() {
} }
return Promise.resolve();
}, },
open: openNotes open: openNotes

View file

@ -22,8 +22,6 @@ var RevealZoom = (function(){
} }
} ); } );
return Promise.resolve();
} }
} }