FIRDocumentChange.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. NS_ASSUME_NONNULL_BEGIN
  18. @class FIRQueryDocumentSnapshot;
  19. #if defined(NS_CLOSED_ENUM)
  20. /** An enumeration of document change types. */
  21. typedef NS_CLOSED_ENUM(NSInteger, FIRDocumentChangeType)
  22. #else
  23. /** An enumeration of document change types. */
  24. typedef NS_ENUM(NSInteger, FIRDocumentChangeType)
  25. #endif
  26. {
  27. /** Indicates a new document was added to the set of documents matching the query. */
  28. FIRDocumentChangeTypeAdded,
  29. /** Indicates a document within the query was modified. */
  30. FIRDocumentChangeTypeModified,
  31. /**
  32. * Indicates a document within the query was removed (either deleted or no longer matches
  33. * the query.
  34. */
  35. FIRDocumentChangeTypeRemoved
  36. } NS_SWIFT_NAME(DocumentChangeType);
  37. /**
  38. * A `DocumentChange` represents a change to the documents matching a query. It contains the
  39. * document affected and the type of change that occurred (added, modified, or removed).
  40. */
  41. NS_SWIFT_SENDABLE
  42. NS_SWIFT_NAME(DocumentChange)
  43. @interface FIRDocumentChange : NSObject
  44. /** :nodoc: */
  45. - (id)init __attribute__((unavailable("FIRDocumentChange cannot be created directly.")));
  46. /** The type of change that occurred (added, modified, or removed). */
  47. @property(nonatomic, readonly) FIRDocumentChangeType type;
  48. /** The document affected by this change. */
  49. @property(nonatomic, strong, readonly) FIRQueryDocumentSnapshot *document;
  50. /**
  51. * The index of the changed document in the result set immediately prior to this `DocumentChange`
  52. * (i.e. supposing that all prior `DocumentChange` objects have been applied). `NSNotFound` for
  53. * `DocumentChangeTypeAdded` events.
  54. */
  55. @property(nonatomic, readonly) NSUInteger oldIndex;
  56. /**
  57. * The index of the changed document in the result set immediately after this `DocumentChange`
  58. * (i.e. supposing that all prior `DocumentChange` objects and the current `DocumentChange` object
  59. * have been applied). `NSNotFound` for `DocumentChangeTypeRemoved` events.
  60. */
  61. @property(nonatomic, readonly) NSUInteger newIndex;
  62. @end
  63. NS_ASSUME_NONNULL_END