FSTFirestoreComponent.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright 2018 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. @class FIRApp;
  18. @class FIRFirestore;
  19. NS_ASSUME_NONNULL_BEGIN
  20. /// Provides and creates instances of Firestore based on a specific key. Used in the interop
  21. /// registration process to keep track of instances for `FIRApp` instances.
  22. @protocol FSTFirestoreMultiDBProvider
  23. /// Cached instances of Firestore objects.
  24. @property(nonatomic, strong) NSMutableDictionary<NSString *, FIRFirestore *> *instances;
  25. /// Default method for retrieving a Firestore instance, or creating one if it doesn't exist.
  26. - (FIRFirestore *)firestoreForDatabase:(NSString *)database;
  27. @end
  28. /// A concrete implementation for FSTInstanceProvider to create Firestore instances and register
  29. /// with Core's component system.
  30. @interface FSTFirestoreComponent : NSObject <FSTFirestoreMultiDBProvider>
  31. /// The FIRApp that instances will be set up with.
  32. @property(nonatomic, weak, readonly) FIRApp *app;
  33. /// Cached instances of Firestore objects.
  34. @property(nonatomic, strong) NSMutableDictionary<NSString *, FIRFirestore *> *instances;
  35. /// Default method for retrieving a Firestore instance, or creating one if it doesn't exist.
  36. - (FIRFirestore *)firestoreForDatabase:(NSString *)database;
  37. /// Default initializer.
  38. - (instancetype)initWithApp:(FIRApp *)app NS_DESIGNATED_INITIALIZER;
  39. - (instancetype)init NS_UNAVAILABLE;
  40. @end
  41. NS_ASSUME_NONNULL_END