diff options
Diffstat (limited to 'Firestore/Source/Util')
-rw-r--r-- | Firestore/Source/Util/FSTAsyncQueryListener.mm | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Firestore/Source/Util/FSTAsyncQueryListener.mm b/Firestore/Source/Util/FSTAsyncQueryListener.mm index d98e2dd..b72ac57 100644 --- a/Firestore/Source/Util/FSTAsyncQueryListener.mm +++ b/Firestore/Source/Util/FSTAsyncQueryListener.mm @@ -34,10 +34,15 @@ } - (FSTViewSnapshotHandler)asyncSnapshotHandler { + // Retain `self` strongly in resulting snapshot handler so that even if the + // user releases the `FSTAsyncQueryListener` we'll continue to deliver + // events. This is done specifically to facilitate the common case where + // users just want to turn on notifications "forever" and don't want to have + // to keep track of our handle to keep them going. return ^(FSTViewSnapshot *_Nullable snapshot, NSError *_Nullable error) { - [_dispatchQueue dispatchAsync:^{ - if (!_muted) { - _snapshotHandler(snapshot, error); + [self->_dispatchQueue dispatchAsync:^{ + if (!self->_muted) { + self->_snapshotHandler(snapshot, error); } }]; }; |