* Run the sequence of phases of hooks, once through. As a result of executing some hooks, more * might be scheduled.
()
| 69 | * might be scheduled. |
| 70 | */ |
| 71 | execute(): void { |
| 72 | const hasSequencesToExecute = this.sequences.size > 0; |
| 73 | |
| 74 | if (hasSequencesToExecute) { |
| 75 | profiler(ProfilerEvent.AfterRenderHooksStart); |
| 76 | } |
| 77 | |
| 78 | this.executing = true; |
| 79 | for (const phase of AFTER_RENDER_PHASES) { |
| 80 | for (const sequence of this.sequences) { |
| 81 | if (sequence.erroredOrDestroyed || !sequence.hooks[phase]) { |
| 82 | continue; |
| 83 | } |
| 84 | |
| 85 | try { |
| 86 | sequence.pipelinedValue = this.ngZone.runOutsideAngular(() => |
| 87 | this.maybeTrace(() => { |
| 88 | const hookFn = sequence.hooks[phase]!; |
| 89 | const value = hookFn(sequence.pipelinedValue); |
| 90 | return value; |
| 91 | }, sequence.snapshot), |
| 92 | ); |
| 93 | } catch (err) { |
| 94 | sequence.erroredOrDestroyed = true; |
| 95 | this.errorHandler?.handleError(err); |
| 96 | } |
| 97 | } |
| 98 | } |
| 99 | this.executing = false; |
| 100 | |
| 101 | // Cleanup step to reset sequence state and also collect one-shot sequences for removal. |
| 102 | for (const sequence of this.sequences) { |
| 103 | sequence.afterRun(); |
| 104 | if (sequence.once) { |
| 105 | this.sequences.delete(sequence); |
| 106 | // Destroy the sequence so its on destroy callbacks can be cleaned up |
| 107 | // immediately, instead of waiting until the injector is destroyed. |
| 108 | sequence.destroy(); |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | for (const sequence of this.deferredRegistrations) { |
| 113 | this.sequences.add(sequence); |
| 114 | } |
| 115 | if (this.deferredRegistrations.size > 0) { |
| 116 | this.scheduler.notify(NotificationSource.RenderHook); |
| 117 | } |
| 118 | this.deferredRegistrations.clear(); |
| 119 | |
| 120 | if (hasSequencesToExecute) { |
| 121 | profiler(ProfilerEvent.AfterRenderHooksEnd); |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | register(sequence: AfterRenderSequence): void { |
| 126 | const {view} = sequence; |
nothing calls this directly
no test coverage detected