Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Batch support for Firestore #361

Merged
merged 20 commits into from
Mar 23, 2018
Merged

Conversation

Skylled
Copy link

@Skylled Skylled commented Jan 12, 2018

Fixes flutter/flutter#14026

I've done some initial testing on Android, including a sync call to an operation followed by an async call.

iOS support is here but needs to be tested.

Copy link
Contributor

@collinjackson collinjackson left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! I have some minor feedback

[batch deleteDocument:reference];
result(nil);
} else if ([@"Batch#commit" isEqualToString:call.method]) {
// TODO:
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you mean to leave this empty TODO?

I think you should remove the batches from the NSDictionary once they are committed

WriteBatch batch = batches.get(handle);
Task<Void> task = batch.commit();
addDefaultListeners("commit", task, result);
break;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you should remove the batches from the SparseArray once they are committed.

final List<Future<Null>> _actions = <Future<Null>>[];

/// Indicator to whether or not this [WriteBatch] has been committed.
bool committed = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be a private property to follow the convention of the Firebase SDK

@@ -36,9 +37,11 @@

// Handles are ints used as indexes into the sparse array of active observers
private int nextHandle = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please rename this nextListenerHandle to better distinguish it from the property below?

@Skylled
Copy link
Author

Skylled commented Jan 13, 2018

Thanks for the feedback. Good catch on removing from the Arrays. That was a memory leak waiting to happen.

Can you confirm for me that it works as expected on iOS? I'm just going by example/instinct with the ObjC code.

Edit: Travis definitely doesn't like it, so that's not a good sign.

@Skylled
Copy link
Author

Skylled commented Jan 24, 2018

Apologies for the messy ObjC. Thanks for the cleanup, @collinjackson

@collinjackson
Copy link
Contributor

After taking a second look at this, I think we want batches to be produced by an instance method of Firestore rather than a constructor. This will more closely match the iOS and Android APIs and will make it easier for us to add multiple app support to this plugin in the future.

@Skylled
Copy link
Author

Skylled commented Feb 5, 2018

Love the design so far.

Will anything need to change on the native side to make that possible? Presently we're using FirebaseFirestore.getInstance. Or will we revisit it with multi-app support?

@collinjackson
Copy link
Contributor

When we implement multiple app support we can fix the native side to look up the appropriate Firestore instance. The API on the Dart side won't change so we won't need to worry about breaking anyone.

@bramvbilsen
Copy link

Any idea for when this will be released?

@Purus
Copy link

Purus commented Mar 7, 2018

Looking for this too..

@collinjackson collinjackson merged commit d0934c0 into flutter:master Mar 23, 2018
slightfoot pushed a commit to slightfoot/plugins that referenced this pull request Jun 5, 2018
@Hixie Hixie removed the needs love label Oct 24, 2018
@tzvc
Copy link
Contributor

tzvc commented Mar 13, 2019

is there any docs for this? :)

@ShiroYacha
Copy link

julianscheel pushed a commit to jusst-engineering/plugins that referenced this pull request Mar 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
8 participants