FRepo.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 synced:(BOOL)synced;
  52. - (NSString *_Nullable)name;
  53. - (NSTimeInterval)serverTime;
  54. - (void)onDataUpdate:(FPersistentConnection *_Nullable)fpconnection
  55. forPath:(NSString *_Nullable)pathString
  56. message:(id _Nullable)message
  57. isMerge:(BOOL)isMerge
  58. tagId:(NSNumber *_Nullable)tagId;
  59. - (void)onConnect:(FPersistentConnection *_Nullable)fpconnection;
  60. - (void)onDisconnect:(FPersistentConnection *_Nullable)fpconnection;
  61. // Disconnect methods
  62. - (void)onDisconnectCancel:(FPath *_Nullable)path
  63. withCallback:(fbt_void_nserror_ref _Nullable)callback;
  64. - (void)onDisconnectSet:(FPath *_Nullable)path
  65. withNode:(id<FNode> _Nullable)node
  66. withCallback:(fbt_void_nserror_ref _Nullable)callback;
  67. - (void)onDisconnectUpdate:(FPath *_Nullable)path
  68. withNodes:(FCompoundWrite *_Nullable)compoundWrite
  69. withCallback:(fbt_void_nserror_ref _Nullable)callback;
  70. // Connection Management.
  71. - (void)interrupt;
  72. - (void)resume;
  73. // Transactions
  74. - (void)startTransactionOnPath:(FPath *_Nullable)path
  75. update:
  76. (fbt_transactionresult_mutabledata _Nullable)update
  77. onComplete:
  78. (fbt_void_nserror_bool_datasnapshot _Nullable)onComplete
  79. withLocalEvents:(BOOL)applyLocally;
  80. // Testing methods
  81. - (NSDictionary *_Nullable)dumpListens;
  82. - (void)dispose;
  83. - (void)setHijackHash:(BOOL)hijack;
  84. @property(nonatomic, strong, readonly) FAuthenticationManager *_Nullable auth;
  85. @property(nonatomic, strong, readonly) FIRDatabase *_Nullable database;
  86. @end