mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-26 01:35:28 +03:00
Add lazy init
This commit is contained in:
parent
21895a6aac
commit
97f35c9724
2 changed files with 153 additions and 4 deletions
|
@ -600,5 +600,77 @@ export class MSPQueueMonitor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Export singleton instance for easy use
|
// Lazy initialization to avoid errors when window.MSP is not yet available
|
||||||
export const mspQueueMonitor = new MSPQueueMonitor(window.MSP);
|
let _mspQueueMonitorInstance = null;
|
||||||
|
|
||||||
|
export const mspQueueMonitor = {
|
||||||
|
get instance() {
|
||||||
|
if (!_mspQueueMonitorInstance) {
|
||||||
|
if (typeof window === "undefined" || !window.MSP) {
|
||||||
|
throw new Error(
|
||||||
|
"MSP Queue Monitor: window.MSP is not available. Make sure MSP is loaded before using the monitor.",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
_mspQueueMonitorInstance = new MSPQueueMonitor(window.MSP);
|
||||||
|
}
|
||||||
|
return _mspQueueMonitorInstance;
|
||||||
|
},
|
||||||
|
|
||||||
|
// Proxy all methods to the lazy-initialized instance
|
||||||
|
startMonitoring(...args) {
|
||||||
|
return this.instance.startMonitoring(...args);
|
||||||
|
},
|
||||||
|
stopMonitoring(...args) {
|
||||||
|
return this.instance.stopMonitoring(...args);
|
||||||
|
},
|
||||||
|
getStatus(...args) {
|
||||||
|
return this.instance.getStatus(...args);
|
||||||
|
},
|
||||||
|
analyzeQueue(...args) {
|
||||||
|
return this.instance.analyzeQueue(...args);
|
||||||
|
},
|
||||||
|
addListener(...args) {
|
||||||
|
return this.instance.addListener(...args);
|
||||||
|
},
|
||||||
|
removeListener(...args) {
|
||||||
|
return this.instance.removeListener(...args);
|
||||||
|
},
|
||||||
|
resetMetrics(...args) {
|
||||||
|
return this.instance.resetMetrics(...args);
|
||||||
|
},
|
||||||
|
clearAlerts(...args) {
|
||||||
|
return this.instance.clearAlerts(...args);
|
||||||
|
},
|
||||||
|
resetAll(...args) {
|
||||||
|
return this.instance.resetAll(...args);
|
||||||
|
},
|
||||||
|
generateReport(...args) {
|
||||||
|
return this.instance.generateReport(...args);
|
||||||
|
},
|
||||||
|
triggerTestAlerts(...args) {
|
||||||
|
return this.instance.triggerTestAlerts(...args);
|
||||||
|
},
|
||||||
|
setTestThresholds(...args) {
|
||||||
|
return this.instance.setTestThresholds(...args);
|
||||||
|
},
|
||||||
|
setNormalThresholds(...args) {
|
||||||
|
return this.instance.setNormalThresholds(...args);
|
||||||
|
},
|
||||||
|
destroy(...args) {
|
||||||
|
return this.instance.destroy(...args);
|
||||||
|
},
|
||||||
|
|
||||||
|
// Getters for properties
|
||||||
|
get isMonitoring() {
|
||||||
|
return this.instance.isMonitoring;
|
||||||
|
},
|
||||||
|
get metrics() {
|
||||||
|
return this.instance.metrics;
|
||||||
|
},
|
||||||
|
get alerts() {
|
||||||
|
return this.instance.alerts;
|
||||||
|
},
|
||||||
|
get thresholds() {
|
||||||
|
return this.instance.thresholds;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
|
@ -590,5 +590,82 @@ export class MSPStressTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Export singleton for easy use
|
// Lazy initialization to avoid errors when window.MSP is not yet available
|
||||||
export const mspStressTest = new MSPStressTest(window.MSP);
|
let _mspStressTestInstance = null;
|
||||||
|
|
||||||
|
export const mspStressTest = {
|
||||||
|
get instance() {
|
||||||
|
if (!_mspStressTestInstance) {
|
||||||
|
if (typeof window === "undefined" || !window.MSP) {
|
||||||
|
throw new Error(
|
||||||
|
"MSP Stress Test: window.MSP is not available. Make sure MSP is loaded before using the stress test.",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
_mspStressTestInstance = new MSPStressTest(window.MSP);
|
||||||
|
}
|
||||||
|
return _mspStressTestInstance;
|
||||||
|
},
|
||||||
|
|
||||||
|
// Proxy all methods to the lazy-initialized instance
|
||||||
|
runStressTestSuite(...args) {
|
||||||
|
return this.instance.runStressTestSuite(...args);
|
||||||
|
},
|
||||||
|
runSpecificTest(...args) {
|
||||||
|
return this.instance.runSpecificTest(...args);
|
||||||
|
},
|
||||||
|
generateTestReport(...args) {
|
||||||
|
return this.instance.generateTestReport(...args);
|
||||||
|
},
|
||||||
|
wait(...args) {
|
||||||
|
return this.instance.wait(...args);
|
||||||
|
},
|
||||||
|
destroy(...args) {
|
||||||
|
return this.instance.destroy(...args);
|
||||||
|
},
|
||||||
|
|
||||||
|
// Test methods
|
||||||
|
testQueueFlooding(...args) {
|
||||||
|
return this.instance.testQueueFlooding(...args);
|
||||||
|
},
|
||||||
|
testRapidFireRequests(...args) {
|
||||||
|
return this.instance.testRapidFireRequests(...args);
|
||||||
|
},
|
||||||
|
testDuplicateRequests(...args) {
|
||||||
|
return this.instance.testDuplicateRequests(...args);
|
||||||
|
},
|
||||||
|
testTimeoutRecovery(...args) {
|
||||||
|
return this.instance.testTimeoutRecovery(...args);
|
||||||
|
},
|
||||||
|
testMemoryLeaks(...args) {
|
||||||
|
return this.instance.testMemoryLeaks(...args);
|
||||||
|
},
|
||||||
|
testConcurrentMixedRequests(...args) {
|
||||||
|
return this.instance.testConcurrentMixedRequests(...args);
|
||||||
|
},
|
||||||
|
testQueueOverflow(...args) {
|
||||||
|
return this.instance.testQueueOverflow(...args);
|
||||||
|
},
|
||||||
|
testConnectionDisruption(...args) {
|
||||||
|
return this.instance.testConnectionDisruption(...args);
|
||||||
|
},
|
||||||
|
testPerformanceUnderLoad(...args) {
|
||||||
|
return this.instance.testPerformanceUnderLoad(...args);
|
||||||
|
},
|
||||||
|
|
||||||
|
// Getters for properties
|
||||||
|
get monitor() {
|
||||||
|
return this.instance.monitor;
|
||||||
|
},
|
||||||
|
get isRunning() {
|
||||||
|
return this.instance.isRunning;
|
||||||
|
},
|
||||||
|
get testResults() {
|
||||||
|
return this.instance.testResults;
|
||||||
|
},
|
||||||
|
get currentTest() {
|
||||||
|
return this.instance.currentTest;
|
||||||
|
},
|
||||||
|
get testCodes() {
|
||||||
|
return this.instance.testCodes;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue