MCPcopy
hub / github.com/meteor/meteor / updateTotalState

Method updateTotalState

tools/console/progress.ts:171–204  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

169
170 // Recomputes state, incorporating children's states
171 private updateTotalState() {
172 let allChildrenDone = true;
173 const state = { ...this.selfState };
174 this.allTasks.forEach(child => {
175 const childState = child.state;
176
177 if (!child.isDone) {
178 allChildrenDone = false;
179 }
180
181 state.current += childState.current;
182 if (state.end !== undefined) {
183 if (childState.done) {
184 state.end += childState.current;
185 } else if (childState.end !== undefined) {
186 state.end += childState.end;
187 } else {
188 state.end = undefined;
189 }
190 }
191 });
192
193 this.isDone = allChildrenDone && !!this.selfState.done;
194 if (!allChildrenDone) {
195 state.done = false;
196 }
197
198 if (!state.done && this.state.done) {
199 // This shouldn't happen
200 throw new Error("Progress transition from done => !done");
201 }
202
203 this.state = state;
204 }
205
206 // Called by a child when its state changes
207 private reportChildState() {

Callers 2

reportProgressMethod · 0.95
reportChildStateMethod · 0.95

Calls 1

forEachMethod · 0.45

Tested by

no test coverage detected