(node: ComputedNode<unknown>)
| 130 | }, |
| 131 | |
| 132 | producerRecomputeValue(node: ComputedNode<unknown>): void { |
| 133 | if (node.value === COMPUTING) { |
| 134 | // Our computation somehow led to a cyclic read of itself. |
| 135 | throw new Error( |
| 136 | typeof ngDevMode !== 'undefined' && ngDevMode ? 'Detected cycle in computations.' : '', |
| 137 | ); |
| 138 | } |
| 139 | |
| 140 | const oldValue = node.value; |
| 141 | node.value = COMPUTING; |
| 142 | |
| 143 | const prevConsumer = consumerBeforeComputation(node); |
| 144 | let newValue: unknown; |
| 145 | let wasEqual = false; |
| 146 | try { |
| 147 | newValue = node.computation(); |
| 148 | // We want to mark this node as errored if calling `equal` throws; however, we don't want |
| 149 | // to track any reactive reads inside `equal`. |
| 150 | setActiveConsumer(null); |
| 151 | wasEqual = |
| 152 | oldValue !== UNSET && |
| 153 | oldValue !== ERRORED && |
| 154 | newValue !== ERRORED && |
| 155 | node.equal(oldValue, newValue); |
| 156 | } catch (err) { |
| 157 | newValue = ERRORED; |
| 158 | node.error = err; |
| 159 | } finally { |
| 160 | consumerAfterComputation(node, prevConsumer); |
| 161 | } |
| 162 | |
| 163 | if (wasEqual) { |
| 164 | // No change to `valueVersion` - old and new values are |
| 165 | // semantically equivalent. |
| 166 | node.value = oldValue; |
| 167 | return; |
| 168 | } |
| 169 | |
| 170 | node.value = newValue; |
| 171 | node.version++; |
| 172 | }, |
| 173 | }; |
| 174 | })(); |
nothing calls this directly
no test coverage detected
searching dependent graphs…