(this: AfterRenderPhaseEffectNode, previousValue?: unknown)
| 107 | this.sequence.scheduler.notify(NotificationSource.RenderHook); |
| 108 | }, |
| 109 | phaseFn(this: AfterRenderPhaseEffectNode, previousValue?: unknown): unknown { |
| 110 | this.sequence.lastPhase = this.phase; |
| 111 | |
| 112 | if (!this.dirty) { |
| 113 | return this.signal; |
| 114 | } |
| 115 | |
| 116 | this.dirty = false; |
| 117 | if (this.value !== NOT_SET && !consumerPollProducersForChange(this)) { |
| 118 | // None of our producers report a change since the last time they were read, so no |
| 119 | // recomputation of our value is necessary. |
| 120 | return this.signal; |
| 121 | } |
| 122 | |
| 123 | // Run any needed cleanup functions. |
| 124 | try { |
| 125 | for (const cleanupFn of this.cleanup ?? EMPTY_CLEANUP_SET) { |
| 126 | cleanupFn(); |
| 127 | } |
| 128 | } finally { |
| 129 | // Even if a cleanup function errors, ensure it's cleared. |
| 130 | this.cleanup?.clear(); |
| 131 | } |
| 132 | |
| 133 | // Prepare to call the user's effect callback. If there was a previous phase, then it gave us |
| 134 | // its value as a `Signal`, otherwise `previousValue` will be `undefined`. |
| 135 | const args: unknown[] = []; |
| 136 | if (previousValue !== undefined) { |
| 137 | args.push(previousValue); |
| 138 | } |
| 139 | args.push(this.registerCleanupFn); |
| 140 | |
| 141 | // Call the user's callback in our reactive context. |
| 142 | const prevConsumer = consumerBeforeComputation(this); |
| 143 | let newValue; |
| 144 | try { |
| 145 | newValue = this.userFn.apply(null, args as any); |
| 146 | } finally { |
| 147 | consumerAfterComputation(this, prevConsumer); |
| 148 | } |
| 149 | |
| 150 | if (this.value === NOT_SET || !this.equal(this.value, newValue)) { |
| 151 | this.value = newValue; |
| 152 | this.version++; |
| 153 | } |
| 154 | |
| 155 | return this.signal; |
| 156 | }, |
| 157 | }))(); |
| 158 | |
| 159 | /** |
nothing calls this directly
no test coverage detected
searching dependent graphs…