Enhance useQuery to manage subscriptions with pause and activate func… #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request refactors the subscription management logic in the
useQueryReact hook to improve how updates are handled during re-observation and to simplify the RxJS integration. The changes introduce a mechanism to pause and resume change notifications, ensuring that updates are not emitted during certain operations, such as re-observing with new options.Improvements to subscription and update management:
observeOn(asapScheduler)and instead introduced apauseChangesflag to control when updates are emitted to React, preventing unnecessary renders during certain operations.lastSubscriptionsymbol property to the observable, storing the current subscription along withpauseChangesandactivateChangesmethods to allow pausing and resuming change notifications.Enhancements to re-observation behavior:
useResubscribeIfNecessaryfunction to pause change notifications before callingreobserveand resume them afterward, preventing intermediate updates during the re-observation process.