Rule Definition
Using delays before calling a data resource may improve the performance of the application applying just enough and just in time policy.
Remediation
Ensure you have provided a debounceTime after calling an Observable
Violation Code Sample
var input = document.getElementById('textInput');
var input$ = Rx.Observable
.fromEvent(input, 'keyup')
.map(x => x.currentTarget.value)
input$.subscribe(x => sendValues(x));
function sendValues(x){
var pre = document.createElement('pre');
pre.innerHTML = JSON.stringify(x);
document.getElementById('results').appendChild(pre);
}
Fixed Code Sample
var input = document.getElementById('textInput');
var input$ = Rx.Observable
.fromEvent(input, 'keyup')
.map(x => x.currentTarget.value)
.debounceTime(500)
input$.subscribe(x => sendValues(x));
function sendValues(x){
var pre = document.createElement('pre');
pre.innerHTML = JSON.stringify(x);
document.getElementById('results').appendChild(pre);
}
Related Technologies
Technical Criterion
CWE-1073 - Non-SQL Invokable Control Element with Excessive Number of Data Resource Accesses
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.