FIRDocumentChange.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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_NAME(DocumentChange)
  42. @interface FIRDocumentChange : NSObject
  43. /** :nodoc: */
  44. - (id)init __attribute__((unavailable("FIRDocumentChange cannot be created directly.")));
  45. /** The type of change that occurred (added, modified, or removed). */
  46. @property(nonatomic, readonly) FIRDocumentChangeType type;
  47. /** The document affected by this change. */
  48. @property(nonatomic, strong, readonly) FIRQueryDocumentSnapshot *document;
  49. /**
  50. * The index of the changed document in the result set immediately prior to this `DocumentChange`
  51. * (i.e. supposing that all prior `DocumentChange` objects have been applied). `NSNotFound` for
  52. * `DocumentChangeTypeAdded` events.
  53. */
  54. @property(nonatomic, readonly) NSUInteger oldIndex;
  55. /**
  56. * The index of the changed document in the result set immediately after this `DocumentChange`
  57. * (i.e. supposing that all prior `DocumentChange` objects and the current `DocumentChange` object
  58. * have been applied). `NSNotFound` for `DocumentChangeTypeRemoved` events.
  59. */
  60. @property(nonatomic, readonly) NSUInteger newIndex;
  61. @end
  62. NS_ASSUME_NONNULL_END