Merge pull request #21 from 67P/feature/wait_for_web3
Pause app boot until window load event fired
This commit was merged in pull request #21.
This commit is contained in:
@@ -13,6 +13,12 @@
|
|||||||
<link rel="stylesheet" href="{{rootURL}}assets/kredits-web.css">
|
<link rel="stylesheet" href="{{rootURL}}assets/kredits-web.css">
|
||||||
|
|
||||||
{{content-for "head-footer"}}
|
{{content-for "head-footer"}}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
window.addEventListener('load', function() {
|
||||||
|
window.windowLoadComplete = true;
|
||||||
|
});
|
||||||
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
{{content-for "body"}}
|
{{content-for "body"}}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
/**
|
||||||
|
* 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) {
|
||||||
|
// Load event already fired, so web3 should be loaded if available
|
||||||
|
if (window.windowLoadComplete) { return true; }
|
||||||
|
|
||||||
|
// Pause app loading
|
||||||
|
application.deferReadiness();
|
||||||
|
|
||||||
|
window.addEventListener('load', function() {
|
||||||
|
// Continue app loading
|
||||||
|
application.advanceReadiness();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user