FSTEventManager.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 <Foundation/Foundation.h>
  17. #include "Firestore/core/src/firebase/firestore/core/view_snapshot.h"
  18. #include "Firestore/core/src/firebase/firestore/model/types.h"
  19. #include "Firestore/core/src/firebase/firestore/util/status.h"
  20. @class FSTQuery;
  21. @class FSTSyncEngine;
  22. NS_ASSUME_NONNULL_BEGIN
  23. #pragma mark - FSTListenOptions
  24. @interface FSTListenOptions : NSObject
  25. + (instancetype)defaultOptions;
  26. - (instancetype)initWithIncludeQueryMetadataChanges:(BOOL)includeQueryMetadataChanges
  27. includeDocumentMetadataChanges:(BOOL)includeDocumentMetadataChanges
  28. waitForSyncWhenOnline:(BOOL)waitForSyncWhenOnline
  29. NS_DESIGNATED_INITIALIZER;
  30. - (instancetype)init NS_UNAVAILABLE;
  31. @property(nonatomic, assign, readonly) BOOL includeQueryMetadataChanges;
  32. @property(nonatomic, assign, readonly) BOOL includeDocumentMetadataChanges;
  33. @property(nonatomic, assign, readonly) BOOL waitForSyncWhenOnline;
  34. @end
  35. #pragma mark - FSTQueryListener
  36. /**
  37. * FSTQueryListener takes a series of internal view snapshots and determines when to raise
  38. * user-facing events.
  39. */
  40. @interface FSTQueryListener : NSObject
  41. - (instancetype)initWithQuery:(FSTQuery *)query
  42. options:(FSTListenOptions *)options
  43. viewSnapshotHandler:(firebase::firestore::core::ViewSnapshotHandler &&)viewSnapshotHandler
  44. NS_DESIGNATED_INITIALIZER;
  45. - (instancetype)init NS_UNAVAILABLE;
  46. - (void)queryDidChangeViewSnapshot:(firebase::firestore::core::ViewSnapshot)snapshot;
  47. - (void)queryDidError:(const firebase::firestore::util::Status &)error;
  48. - (void)applyChangedOnlineState:(firebase::firestore::model::OnlineState)onlineState;
  49. @property(nonatomic, strong, readonly) FSTQuery *query;
  50. @end
  51. #pragma mark - FSTEventManager
  52. /**
  53. * EventManager is responsible for mapping queries to query event emitters. It handles "fan-out."
  54. * (Identical queries will re-use the same watch on the backend.)
  55. */
  56. @interface FSTEventManager : NSObject
  57. + (instancetype)eventManagerWithSyncEngine:(FSTSyncEngine *)syncEngine;
  58. - (instancetype)init __attribute__((unavailable("Use static constructor method.")));
  59. - (firebase::firestore::model::TargetId)addListener:(FSTQueryListener *)listener;
  60. - (void)removeListener:(FSTQueryListener *)listener;
  61. - (void)applyChangedOnlineState:(firebase::firestore::model::OnlineState)onlineState;
  62. @end
  63. NS_ASSUME_NONNULL_END