feat(connect): enhance reducer behavior for falsy values in signal up… - #696
Conversation
|
View your CI Pipeline Execution ↗ for commit 6780d96
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Code Review
This pull request fixes an issue in the connect function where a reducer returning a falsy value (such as false or 0) would incorrectly fall back to the raw emission due to the logical OR (||) operator. The code has been updated to use a ternary operator (reducer ? reducer(prev, x) : x) to ensure falsy values from the reducer are preserved. Additionally, comprehensive unit tests have been added to verify this behavior. There are no review comments, and I have no further feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
reducer?.(prev, x) || xis meant to say "if a reducer was provided, use its result; otherwise use the raw emitted value x." But || only checks truthiness, not whether the reducer ran.So if the reducer is defined and legitimately computes a falsy value (
0, '', false, null, ect) the || treats that as "nothing," discards it, and silently substitutes the raw x from the observable instead.