Skip to content

CrudBatch hasMore + onChange improvement #182

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

Merged
merged 3 commits into from
Apr 29, 2025
Merged

CrudBatch hasMore + onChange improvement #182

merged 3 commits into from
Apr 29, 2025

Conversation

stevensJourney
Copy link
Contributor

Overview

CrudBatch

This fixes a bug where the hasMore value of CrudBatch was always false.

onChange

This adds a triggerImmediately parameter to the onChange API similar to the Dart API. Adding this makes it easy to avoid race conditions in consumers such as the Swift SDK.

@stevensJourney stevensJourney requested a review from simolus3 April 29, 2025 14:29
@stevensJourney stevensJourney marked this pull request as ready for review April 29, 2025 14:29
simolus3
simolus3 previously approved these changes Apr 29, 2025
Copy link
Contributor

@simolus3 simolus3 left a comment

Choose a reason for hiding this comment

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

The CRUD changes look good to me.

Adding this makes it easy to avoid race conditions in consumers such as the Swift SDK.

What race conditions are we aiming to avoid with this? It's not immediately clear to me, so maybe you have an example where it helps that we have an initial emit right away?

@stevensJourney
Copy link
Contributor Author

The CRUD changes look good to me.

Adding this makes it easy to avoid race conditions in consumers such as the Swift SDK.

What race conditions are we aiming to avoid with this? It's not immediately clear to me, so maybe you have an example where it helps that we have an initial emit right away?

In Swift we'd like to use the onChange method to implement the watch method. Doing this gives the Swift SDK the ability to control and catch any exceptions which might occur when performing the corresponding getAll query.

It can become tricky to control the emission of the first watched query result and starting a Task which listens to events from an onChange stream and then executes a getAll updating the resultant stream. It's not impossible to manage this, but having the onChange method emit an initial event makes the implementation much simpler.

Copy link
Contributor

@simolus3 simolus3 left a comment

Choose a reason for hiding this comment

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

I see, thanks for the explanation 👍

@stevensJourney stevensJourney merged commit e3996e7 into main Apr 29, 2025
3 checks passed
@stevensJourney stevensJourney deleted the crudhasmore branch April 29, 2025 16:02
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