aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHakim El Hattab <hakim.elhattab@gmail.com>2019-04-03 10:49:14 +0200
committerGitHub <noreply@github.com>2019-04-03 10:49:14 +0200
commit3643112b35255b2fddf21041343b31cc64222fb1 (patch)
treeff8463c7576f7a1435385f00d91e8088d572d67b
parent15dec96e73f2bc8ee8984d7e53828b6417eabf46 (diff)
downloadperl-software-in-gnu-guix-3643112b35255b2fddf21041343b31cc64222fb1.tar
perl-software-in-gnu-guix-3643112b35255b2fddf21041343b31cc64222fb1.tar.gz
plugin doc tweaks
-rw-r--r--README.md11
1 files changed, 6 insertions, 5 deletions
diff --git a/README.md b/README.md
index f6eee5e..33956e9 100644
--- a/README.md
+++ b/README.md
@@ -1235,19 +1235,20 @@ Then:
## Plugins
-Plugins should be registered with reveal.js by calling `Reveal.registerPlugin( 'myPluginID', MyPlugin )`. Registered plugin instances should expose an "init" function that reveal.js can call to initialize them.
+Plugins should register themselves with reveal.js by calling `Reveal.registerPlugin( 'myPluginID', MyPlugin )`. Registered plugin instances can optionally expose an "init" function that reveal.js will call to initialize them.
-When reveal.js is booted up via `Reveal.initialize()`, it will go through all registered plugins and invoke their "init" methods. If the "init" method returns a Promise, reveal.js will wait for that promise to be fullfilled before finshing the startup sequence and firing the [ready](#ready-event) event. Here's an example of a plugin that returns a promise:
+When reveal.js is booted up via `Reveal.initialize()`, it will go through all registered plugins and invoke their "init" methods. If the "init" method returns a Promise, reveal.js will wait for that promise to be fullfilled before finshing the startup sequence and firing the [ready](#ready-event) event. Here's an example of a plugin that does some asynchronous work before reveal.js can proceed:
```javascript
-Reveal.registerPlugin( 'myPlugin', {
+let MyPlugin = {
init: () => new Promise( resolve => setTimeout( resolve, 3000 ) )
-} );
+};
+Reveal.registerPlugin( 'myPlugin', MyPlugin );
Reveal.addEventListener( 'ready', () => console.log( 'Three seconds later...' ) );
Reveal.initialize();
```
-If the init method does _not_ return a Promise, it is considered ready right away and will not hold up the reveal.js startup sequence.
+If the init method does _not_ return a Promise, the plugin is considered ready right away and will not hold up the reveal.js startup sequence.
### Retrieving Plugins