diff options
author | 2017-10-11 04:51:05 +0200 | |
---|---|---|
committer | 2017-10-11 04:51:05 +0200 | |
commit | ae171bb226246e8b485f688e6ddf2dd8dc9fa9be (patch) | |
tree | b28eb368904608f8a466b0ced9a4606e193c7efe /Firestore/Source/Core | |
parent | 73d5cffffd3c5cc3f1f9b92db1bcbc26739cf1bc (diff) |
Adding goOnline/goOffline to the RemoteStore (#347)
Diffstat (limited to 'Firestore/Source/Core')
-rw-r--r-- | Firestore/Source/Core/FSTFirestoreClient.h | 6 | ||||
-rw-r--r-- | Firestore/Source/Core/FSTFirestoreClient.m | 22 |
2 files changed, 28 insertions, 0 deletions
diff --git a/Firestore/Source/Core/FSTFirestoreClient.h b/Firestore/Source/Core/FSTFirestoreClient.h index 45f13cc..21d61d4 100644 --- a/Firestore/Source/Core/FSTFirestoreClient.h +++ b/Firestore/Source/Core/FSTFirestoreClient.h @@ -56,6 +56,12 @@ NS_ASSUME_NONNULL_BEGIN /** Shuts down this client, cancels all writes / listeners, and releases all resources. */ - (void)shutdownWithCompletion:(nullable FSTVoidErrorBlock)completion; +/** Disables the network connection. Pending operations will not complete. */ +- (void)disableNetworkWithCompletion:(nullable FSTVoidErrorBlock)completion; + +/** Enables the network connection and requeues all pending operations. */ +- (void)enableNetworkWithCompletion:(nullable FSTVoidErrorBlock)completion; + /** Starts listening to a query. */ - (FSTQueryListener *)listenToQuery:(FSTQuery *)query options:(FSTListenOptions *)options diff --git a/Firestore/Source/Core/FSTFirestoreClient.m b/Firestore/Source/Core/FSTFirestoreClient.m index 2066ce9..1a53197 100644 --- a/Firestore/Source/Core/FSTFirestoreClient.m +++ b/Firestore/Source/Core/FSTFirestoreClient.m @@ -187,6 +187,28 @@ NS_ASSUME_NONNULL_BEGIN [self.syncEngine userDidChange:user]; } +- (void)disableNetworkWithCompletion:(nullable FSTVoidErrorBlock)completion { + [self.workerDispatchQueue dispatchAsync:^{ + [self.remoteStore disableNetwork]; + if (completion) { + [self.userDispatchQueue dispatchAsync:^{ + completion(nil); + }]; + } + }]; +} + +- (void)enableNetworkWithCompletion:(nullable FSTVoidErrorBlock)completion { + [self.workerDispatchQueue dispatchAsync:^{ + [self.remoteStore enableNetwork]; + if (completion) { + [self.userDispatchQueue dispatchAsync:^{ + completion(nil); + }]; + } + }]; +} + - (void)shutdownWithCompletion:(nullable FSTVoidErrorBlock)completion { [self.workerDispatchQueue dispatchAsync:^{ self.credentialsProvider.userChangeListener = nil; |