aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorHakim El Hattab <hakim.elhattab@gmail.com>2019-03-14 14:52:59 +0100
committerHakim El Hattab <hakim.elhattab@gmail.com>2019-03-14 14:52:59 +0100
commit6410ed15aa5ce2bdfc1f7f02c818a562ec8a1fc4 (patch)
tree2dfb0a67422aa196b9448c1e3c06338dfb20131f /js
parent5301a9ea03a2c5abe857105acbc224c532a8c0e8 (diff)
downloadperl-software-in-gnu-guix-6410ed15aa5ce2bdfc1f7f02c818a562ec8a1fc4.tar
perl-software-in-gnu-guix-6410ed15aa5ce2bdfc1f7f02c818a562ec8a1fc4.tar.gz
support for plugins where the init method doesn't return a Promise
Diffstat (limited to 'js')
-rw-r--r--js/reveal.js29
1 files changed, 17 insertions, 12 deletions
diff --git a/js/reveal.js b/js/reveal.js
index 1ef10aa..51b1ed0 100644
--- a/js/reveal.js
+++ b/js/reveal.js
@@ -539,29 +539,34 @@
var pluginsToInitialize = Object.keys( plugins ).length;
+ var afterPlugInitialized = function() {
+ if( --pluginsToInitialize === 0 ) {
+ loadAsyncDependencies();
+ }
+ };
+
for( var i in plugins ) {
var plugin = plugins[i];
- // If the plugin has an 'init' method, initialize and
- // wait for the callback
+ // If the plugin has an 'init' method, invoke it
if( typeof plugin.init === 'function' ) {
- plugin.init().then( function() {
- if( --pluginsToInitialize === 0 ) {
- loadAsyncDependencies();
- }
- } );
+ var callback = plugin.init();
+
+ // If the plugin returned a Promise, wait for it
+ if( callback && typeof callback.then === 'function' ) {
+ callback.then( afterPlugInitialized );
+ }
+ else {
+ afterPlugInitialized();
+ }
}
else {
- pluginsToInitialize -= 1;
+ afterPlugInitialized();
}
}
- if( pluginsToInitialize === 0 ) {
- loadAsyncDependencies();
- }
-
}
/**