* window.ForemMobile namespaced functions * Fix broken Buildkite * Wait for data-loaded before using Runtime in pack * Bring back sprockets base * Better error handling * Smal fixes to ConsumerApp to support Android platform * Fix typo * utilities/waitForDataLoaded.js * Update app/javascript/utilities/waitForDataLoaded.js Co-authored-by: Nick Taylor <nick@forem.com> * Review feedback * Fix failing spec * Cleanup promise * Remove old utility file * Add Cypress check for namespaced availability * More specs * Refactor to rely on ForemMobile for native bridge messaging * Fix spec/requests/api/v0/instances_spec.rb * Fix devices spec * Remove changes to /api/instance * Refactor to dynamic import * Fix typo * Fixed custom event detail payload for tests. * mock ForemMobile function instead of webkit call directly * failing jest test debug * Another attempt * Fixed broken test that was missing an onMainImageUrlChange prop on the component. * Fixed mobile bridging E2E tests. * Move Cypress tests to mobileFlows * Add JSDocs + cypress spec for injectJSMessage when logged out * Cleanup + Disable native image upload until AppStore approval Co-authored-by: Nick Taylor <nick@forem.com> Co-authored-by: Nick Taylor <nick@dev.to>
20 lines
752 B
JavaScript
20 lines
752 B
JavaScript
/**
|
|
* A util function to wrap any code that needs to wait until the page has
|
|
* initialized correctly before executing. This is generally the case for
|
|
* packs/components that require `/app/assets/initializers` to execute first,
|
|
* this way you're ensured that global functions/namespaces will be available
|
|
* (i.e. the Runtime class).
|
|
*
|
|
* @returns {Promise} A chainable promise that will fulfill when the page has
|
|
* loaded correctly and all initializers have run.
|
|
*/
|
|
export function waitOnBaseData() {
|
|
return new Promise((resolve) => {
|
|
const waitingForDataLoad = setInterval(() => {
|
|
if (document.body.getAttribute('data-loaded') === 'true') {
|
|
clearInterval(waitingForDataLoad);
|
|
resolve();
|
|
}
|
|
}, 100);
|
|
});
|
|
}
|