avocado-old/packages/state/synchronizer.js

29 lines
666 B
JavaScript
Raw Normal View History

2019-03-20 18:33:13 -05:00
import * as I from 'immutable';
2019-04-07 15:46:07 -05:00
import {nextStep} from './next-step';
2019-04-07 20:04:40 -05:00
export class Synchronizer {
2019-03-20 18:33:13 -05:00
2019-05-13 21:07:51 -05:00
constructor(children) {
this.children = children;
2019-03-20 18:33:13 -05:00
}
2019-05-13 21:07:51 -05:00
acceptPacket(packet) {
for (let i = 0; i < this.children.length; i++) {
this.children[i].acceptPacket(packet);
2019-04-05 15:16:55 -05:00
}
}
2019-05-13 21:07:51 -05:00
packetsForUpdate(force = false) {
const packetsForUpdate = [];
for (let i = 0; i < this.children.length; i++) {
const childPacketsForUpdate = this.children[i].packetsForUpdate(force);
for (let j = 0; j < childPacketsForUpdate.length; j++) {
packetsForUpdate.push(childPacketsForUpdate[j]);
}
2019-04-23 15:25:03 -05:00
}
2019-05-13 21:07:51 -05:00
return packetsForUpdate;
2019-03-20 18:33:13 -05:00
}
}