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