MCPcopy
hub / github.com/angular/angular / trigger

Method trigger

packages/service-worker/worker/src/idle.ts:37–66  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

35 ) {}
36
37 async trigger(): Promise<void> {
38 this.lastTrigger = this.adapter.time;
39 if (this.queue.length === 0) {
40 return;
41 }
42
43 if (this.scheduled !== null) {
44 this.scheduled.cancel = true;
45 }
46
47 const scheduled = {
48 cancel: false,
49 };
50 this.scheduled = scheduled;
51
52 // Ensure that no task remains pending for longer than `this.maxDelay` ms.
53 const now = this.adapter.time;
54 const maxDelay = Math.max(0, (this.oldestScheduledAt ?? now) + this.maxDelay - now);
55 const delay = Math.min(maxDelay, this.delay);
56
57 await this.adapter.timeout(delay);
58
59 if (scheduled.cancel) {
60 return;
61 }
62
63 this.scheduled = null;
64
65 await this.execute();
66 }
67
68 async execute(): Promise<void> {
69 this.lastRun = this.adapter.time;

Callers 6

idle_spec.tsFile · 0.45
onFetchMethod · 0.45
ensureInitializedMethod · 0.45
handleFetchMethod · 0.45
onContextMenuMethod · 0.45
closeContextMenuMethod · 0.45

Calls 4

executeMethod · 0.95
maxMethod · 0.45
minMethod · 0.45
timeoutMethod · 0.45

Tested by

no test coverage detected