Skip to content

feat(connect): enhance reducer behavior for falsy values in signal up… - #696

Merged
eneajaho merged 1 commit into
ngxtension:mainfrom
endlacer:feature/fix-connect-falsy-reducer
Jul 3, 2026
Merged

feat(connect): enhance reducer behavior for falsy values in signal up…#696
eneajaho merged 1 commit into
ngxtension:mainfrom
endlacer:feature/fix-connect-falsy-reducer

Conversation

@endlacer

@endlacer endlacer commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

reducer?.(prev, x) || x is 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.

@nx-cloud

nx-cloud Bot commented Jul 3, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 6780d96

Command Status Duration Result
nx affected --target=build --parallel=3 --exclu... ✅ Succeeded <1s View ↗
nx affected --target=test --parallel=3 --exclud... ✅ Succeeded 6s View ↗
nx affected --target=lint --parallel=3 ✅ Succeeded 17s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 2s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-07-03 06:51:55 UTC

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@eneajaho eneajaho left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@eneajaho
eneajaho merged commit 26c26ee into ngxtension:main Jul 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants