Skip to content

Commit

Permalink
Add optional main collection check to SmartEnv.wait_for method
Browse files Browse the repository at this point in the history
- Introduced new option to wait for specific main collection loading
- Increased interval to 1000ms for main collection check
- Maintained existing collections_loaded check as default behavior
  • Loading branch information
Brian Joseph Petro committed Feb 11, 2025
1 parent 2833f1a commit a8cbfef
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions smart-environment/smart_env.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,21 @@ export class SmartEnv {

static wait_for(opts = {}) {
return new Promise((resolve) => {
const interval = setInterval(() => {
if (window.smart_env && window.smart_env.collections_loaded) {
clearInterval(interval);
resolve(window.smart_env);
}
}, 100);
if (opts.main) {
const interval = setInterval(() => {
if (window.smart_env && window.smart_env.mains.includes(opts.main)) {
clearInterval(interval);
resolve(window.smart_env);
}
}, 1000);
} else {
const interval = setInterval(() => {
if (window.smart_env && window.smart_env.collections_loaded) {
clearInterval(interval);
resolve(window.smart_env);
}
}, 100);
}
});
}

Expand Down

0 comments on commit a8cbfef

Please sign in to comment.