MCPcopy
hub / github.com/ampproject/amphtml / schedule

Method schedule

src/pass.js:64–84  ·  view source on GitHub ↗

* Tries to schedule a new pass optionally with specified delay. If the new * requested pass is requested before the pending pass, the pending pass is * canceled. If the new pass is requested after the pending pass, the newly * requested pass is ignored. * * Returns true if the

(opt_delay)

Source from the content-addressed store, hash-verified

62 * @return {boolean}
63 */
64 schedule(opt_delay) {
65 let delay = opt_delay || this.defaultDelay_;
66 if (this.running_ && delay < 10) {
67 // If we get called recursively, wait at least 10ms for the next
68 // execution.
69 delay = 10;
70 }
71
72 const nextTime = Date.now() + delay;
73 // Schedule anew if nothing is scheduled currently or if the new time is
74 // sooner then previously requested.
75 if (!this.isPending() || nextTime - this.nextTime_ < -10) {
76 this.cancel();
77 this.nextTime_ = nextTime;
78 this.scheduled_ = this.timer_.delay(this.boundPass_, delay);
79
80 return true;
81 }
82
83 return false;
84 }
85
86 /**
87 *

Callers 7

test-scheduler.jsFile · 0.45
test-pass.jsFile · 0.45
doPass_Method · 0.45
upgradeOrSchedule_Method · 0.45
scheduleRender_Method · 0.45
scheduleNextPassMethod · 0.45
onResize_Method · 0.45

Calls 4

isPendingMethod · 0.95
cancelMethod · 0.95
nowMethod · 0.80
delayMethod · 0.80

Tested by

no test coverage detected