refactor: simplify splice
This commit is contained in:
parent
4f59ddd731
commit
32fa9ee257
|
@ -4,29 +4,23 @@ export default class Ticking extends Component {
|
|||
instanceFromSchema() {
|
||||
return class TickingInstance extends super.instanceFromSchema() {
|
||||
|
||||
$$finished = [];
|
||||
$$tickers = [];
|
||||
|
||||
add(ticker) {
|
||||
this.$$tickers.push(ticker);
|
||||
ticker.then(() => {
|
||||
this.$$finished.push(ticker);
|
||||
});
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.$$finished = [];
|
||||
this.$$tickers = [];
|
||||
}
|
||||
|
||||
tick(elapsed) {
|
||||
for (const ticker of this.$$finished) {
|
||||
this.$$tickers.splice(
|
||||
this.$$tickers.indexOf(ticker),
|
||||
1,
|
||||
);
|
||||
}
|
||||
this.$$finished = [];
|
||||
});
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.$$tickers = [];
|
||||
}
|
||||
|
||||
tick(elapsed) {
|
||||
for (const ticker of this.$$tickers) {
|
||||
ticker.tick(elapsed);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user