Skip to content

fix(angular-query): ensure initial mutation pending state is emitted #9098

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ThiloAschebrock
Copy link

Fixes #9020

The issue was that the effect that subscribes to the observer runs after the observer emits the first state change if the mutation is triggered in the constructor of a component or ngOnInit. This is fixed by immediately subscribing when the initial result is computed.

One could also consider combining resultFromSubscriberSignal and resultFromInitialOptionsSignal into a single linkedSignal, but this would require dropping support for Angular 18.

@ThiloAschebrock ThiloAschebrock force-pushed the bugfix/mutation-skips-pending-state branch from b4722f2 to 5c6a9de Compare May 23, 2025 23:25
@ThiloAschebrock
Copy link
Author

Removed the last effect of injectMutation in 9fcd7dd that was causing scenarios where the mutation function could be out of sync with the provided options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Angular: injectMutation skips pending state when triggered in constructor or ngOnInit
1 participant