Fix startup race condition
Summary: Currently Flipper.init is called as soon as the script loads. However, if the store takes a bit longer than usual to get rehydrated, then this init call can get called before it has been set. Fixing it by using a specific event instead of the generic `onload`. Reviewed By: passy Differential Revision: D17711399 fbshipit-source-id: fcaf9e5943bfd15359038b8e3722f11d7e06379b
This commit is contained in:
committed by
Facebook Github Bot
parent
b3a98dc5e5
commit
957427d740
@@ -88,4 +88,5 @@ persistStore(store, undefined, () => {
|
|||||||
dispatcher(store, logger);
|
dispatcher(store, logger);
|
||||||
// make init function callable from outside
|
// make init function callable from outside
|
||||||
window.Flipper.init = init;
|
window.Flipper.init = init;
|
||||||
|
window.dispatchEvent(new Event('flipper-store-ready'));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -85,13 +85,10 @@
|
|||||||
openError('Script failure. Check Chrome console for more info.');
|
openError('Script failure. Check Chrome console for more info.');
|
||||||
};
|
};
|
||||||
|
|
||||||
script.onload = () => {
|
window.addEventListener('flipper-store-ready', () => global.Flipper.init());
|
||||||
global.Flipper.init();
|
|
||||||
};
|
|
||||||
|
|
||||||
document.body.appendChild(script);
|
document.body.appendChild(script);
|
||||||
}
|
}
|
||||||
|
|
||||||
init();
|
init();
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -13,9 +13,9 @@
|
|||||||
<script>
|
<script>
|
||||||
global.electronRequire = window.require;
|
global.electronRequire = window.require;
|
||||||
</script>
|
</script>
|
||||||
<script src="bundle.js"></script>
|
|
||||||
<script>
|
<script>
|
||||||
global.Flipper.init();
|
window.addEventListener('flipper-store-ready', () => global.Flipper.init());
|
||||||
</script>
|
</script>
|
||||||
|
<script src="bundle.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user