'Stencil JS globalscript is not completing before app loads
Need to initialize indexedDB before any component loads. Tried using the global script to do this but the global script default function does not complete before components load. For example if I set a timeout in the default function for 30 seconds the components still load and do not wait for the function to complete. Read documentation and states "The global script runs once BEFORE your library/app loads." This is not happening.
Need some suggestions on how to achieve my goal or possible reasons why global scripts is behaving as such. Tried setting up the global script both async and sync.
Solution 1:[1]
Was using setTimeout() to create a pause which is not correct. "setTimeout() is an asynchronous function, meaning that the timer function will not pause execution of other functions in the functions stack." Stencil globalscript is working as expected.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | runr2002 |
