FRepo.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import "FirebaseDatabase/Sources/Core/FPersistentConnection.h"
  17. #import "FirebaseDatabase/Sources/Core/FRepoInfo.h"
  18. #import "FirebaseDatabase/Sources/Public/FirebaseDatabase/FIRDataEventType.h"
  19. #import "FirebaseDatabase/Sources/Public/FirebaseDatabase/FIRDatabaseQuery.h"
  20. #import "FirebaseDatabase/Sources/Utilities/Tuples/FTupleUserCallback.h"
  21. #import <Foundation/Foundation.h>
  22. @class FQuerySpec;
  23. @class FPersistence;
  24. @class FAuthenticationManager;
  25. @class FIRDatabaseConfig;
  26. @protocol FEventRegistration;
  27. @class FCompoundWrite;
  28. @protocol FClock;
  29. @class FIRDatabase;
  30. @interface FRepo : NSObject <FPersistentConnectionDelegate>
  31. @property(nonatomic, strong) FIRDatabaseConfig *_Nullable config;
  32. - (id _Nonnull)initWithRepoInfo:(FRepoInfo *_Nullable)info
  33. config:(FIRDatabaseConfig *_Nullable)config
  34. database:(FIRDatabase *_Nullable)database;
  35. - (void)set:(FPath *_Nullable)path
  36. withNode:(id _Nullable)node
  37. withCallback:(fbt_void_nserror_ref _Nullable)onComplete;
  38. - (void)update:(FPath *_Nullable)path
  39. withNodes:(FCompoundWrite *_Nullable)compoundWrite
  40. withCallback:(fbt_void_nserror_ref _Nullable)callback;
  41. - (void)purgeOutstandingWrites;
  42. - (void)getData:(FIRDatabaseQuery *_Nullable)query
  43. withCompletionBlock:
  44. (void (^_Nonnull)(NSError *_Nullable error,
  45. FIRDataSnapshot *_Nullable snapshot))block;
  46. - (void)addEventRegistration:(id<FEventRegistration> _Nullable)eventRegistration
  47. forQuery:(FQuerySpec *_Nullable)query;
  48. - (void)removeEventRegistration:
  49. (id<FEventRegistration> _Nullable)eventRegistration
  50. forQuery:(FQuerySpec *_Nullable)query;
  51. - (void)keepQuery:(FQuerySpec *_Nullable)query
  52. synced:(BOOL)synced
  53. skipListen:(BOOL)skip;
  54. - (void)keepQuery:(FQuerySpec *_Nullable)query synced:(BOOL)synced;
  55. - (NSString *_Nullable)name;
  56. - (NSTimeInterval)serverTime;
  57. - (void)onDataUpdate:(FPersistentConnection *_Nullable)fpconnection
  58. forPath:(NSString *_Nullable)pathString
  59. message:(id _Nullable)message
  60. isMerge:(BOOL)isMerge
  61. tagId:(NSNumber *_Nullable)tagId;
  62. - (void)onConnect:(FPersistentConnection *_Nullable)fpconnection;
  63. - (void)onDisconnect:(FPersistentConnection *_Nullable)fpconnection;
  64. // Disconnect methods
  65. - (void)onDisconnectCancel:(FPath *_Nullable)path
  66. withCallback:(fbt_void_nserror_ref _Nullable)callback;
  67. - (void)onDisconnectSet:(FPath *_Nullable)path
  68. withNode:(id<FNode> _Nullable)node
  69. withCallback:(fbt_void_nserror_ref _Nullable)callback;
  70. - (void)onDisconnectUpdate:(FPath *_Nullable)path
  71. withNodes:(FCompoundWrite *_Nullable)compoundWrite
  72. withCallback:(fbt_void_nserror_ref _Nullable)callback;
  73. // Connection Management.
  74. - (void)interrupt;
  75. - (void)resume;
  76. // Transactions
  77. - (void)startTransactionOnPath:(FPath *_Nullable)path
  78. update:
  79. (fbt_transactionresult_mutabledata _Nullable)update
  80. onComplete:
  81. (fbt_void_nserror_bool_datasnapshot _Nullable)onComplete
  82. withLocalEvents:(BOOL)applyLocally;
  83. // Testing methods
  84. - (NSDictionary *_Nullable)dumpListens;
  85. - (void)dispose;
  86. - (void)setHijackHash:(BOOL)hijack;
  87. @property(nonatomic, strong, readonly) FAuthenticationManager *_Nullable auth;
  88. @property(nonatomic, strong, readonly) FIRDatabase *_Nullable database;
  89. @end