Pattern: Use of setTimeout/setInterval
in asyncData/fetch
Issue: -
This rule is for preventing using setTimeout/setInterval
in asyncData/fetch
since it may lead to memory leak.
Examples of incorrect code for this rule:
export default {
asyncData() {
let foo = 'bar'
setTimeout(() => {
foo = 'baz'
}, 0)
},
fetch() {
let foo = 'bar'
setInterval(() => {
foo = 'baz'
}, 0)
}
}
Examples of correct code for this rule:
export default {
async asyncData() {
let foo = 'baz'
},
fetch() {
let foo = 'baz'
}
}