MCPcopy Create free account
hub / github.com/Comfy-Org/litegraph.js / start

Method start

src/LGraph.ts:384–421  ·  view source on GitHub ↗

* @deprecated Will be removed in 0.9 * Starts running this graph every interval milliseconds. * @param interval amount of milliseconds between executions, if 0 then it renders to the monitor refresh rate

(interval?: number)

Source from the content-addressed store, hash-verified

382 * @param interval amount of milliseconds between executions, if 0 then it renders to the monitor refresh rate
383 */
384 start(interval?: number): void {
385 if (this.status == LGraph.STATUS_RUNNING) return
386 this.status = LGraph.STATUS_RUNNING
387
388 this.onPlayEvent?.()
389 this.sendEventToAllNodes("onStart")
390
391 // launch
392 this.starttime = LiteGraph.getTime()
393 this.last_update_time = this.starttime
394 interval ||= 0
395
396 // execute once per frame
397 if (
398 interval == 0 &&
399 typeof window != "undefined" &&
400 window.requestAnimationFrame
401 ) {
402 const on_frame = () => {
403 if (this.execution_timer_id != -1) return
404
405 window.requestAnimationFrame(on_frame)
406 this.onBeforeStep?.()
407 this.runStep(1, !this.catch_errors)
408 this.onAfterStep?.()
409 }
410 this.execution_timer_id = -1
411 on_frame()
412 } else {
413 // execute every 'interval' ms
414 this.execution_timer_id = setInterval(() => {
415 // execute
416 this.onBeforeStep?.()
417 this.runStep(1, !this.catch_errors)
418 this.onAfterStep?.()
419 }, interval)
420 }
421 }
422
423 /**
424 * @deprecated Will be removed in 0.9

Callers

nothing calls this directly

Calls 3

sendEventToAllNodesMethod · 0.95
runStepMethod · 0.95
getTimeMethod · 0.45

Tested by

no test coverage detected