From e51586a78cf3089c3aa4d10edb7e17be9deb74e5 Mon Sep 17 00:00:00 2001 From: Garret Alfert Date: Tue, 13 Jun 2017 13:13:59 +0200 Subject: [PATCH] Pause app boot until window load event fired Refs #17 Allows the user provided Web3 instance to be inserted before we try to use it. --- app/initializers/defer-loading.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 app/initializers/defer-loading.js diff --git a/app/initializers/defer-loading.js b/app/initializers/defer-loading.js new file mode 100644 index 0000000..c6e8c28 --- /dev/null +++ b/app/initializers/defer-loading.js @@ -0,0 +1,15 @@ +/** + * This pauses the app's boot process until the window load event is fired. + * It allows the user provided Web3 instance (e.g. Metamask, Mist Browser) + * to be inserted before we try to use it. + */ +export default { + name: 'defer-loading', + initialize: function(application) { + application.deferReadiness(); + + window.addEventListener('load', function() { + application.advanceReadiness(); + }); + } +};