mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-22 07:45:29 +03:00
clear callbacks the smarter way
This commit is contained in:
parent
781d058228
commit
927589e22f
1 changed files with 7 additions and 6 deletions
|
@ -68,12 +68,13 @@ var MSP = {
|
||||||
packet_error: 0,
|
packet_error: 0,
|
||||||
|
|
||||||
callbacks_cleanup: function() {
|
callbacks_cleanup: function() {
|
||||||
for (var i = 0; i < this.callbacks.length; i++) {
|
for (var i = (this.callbacks.length - 1); i >= 0; i--) {
|
||||||
|
// kill timer
|
||||||
clearInterval(this.callbacks[i].timer);
|
clearInterval(this.callbacks[i].timer);
|
||||||
}
|
|
||||||
|
|
||||||
// drop references
|
// remove object/reference
|
||||||
this.callbacks = [];
|
this.callbacks.splice(i, 1);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
disconnect_cleanup: function() {
|
disconnect_cleanup: function() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue