You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
2.4 KiB

  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 "Private/FIRComponent.h"
  17. #import "Private/FIRComponentContainer.h"
  18. #import "Private/FIRDependency.h"
  19. @interface FIRComponent ()
  20. - (instancetype)initWithProtocol:(Protocol *)protocol
  21. instantiationTiming:(FIRInstantiationTiming)instantiationTiming
  22. dependencies:(NSArray<FIRDependency *> *)dependencies
  23. creationBlock:(FIRComponentCreationBlock)creationBlock;
  24. @end
  25. @implementation FIRComponent
  26. + (instancetype)componentWithProtocol:(Protocol *)protocol
  27. creationBlock:(FIRComponentCreationBlock)creationBlock {
  28. return [[FIRComponent alloc] initWithProtocol:protocol
  29. instantiationTiming:FIRInstantiationTimingLazy
  30. dependencies:@[]
  31. creationBlock:creationBlock];
  32. }
  33. + (instancetype)componentWithProtocol:(Protocol *)protocol
  34. instantiationTiming:(FIRInstantiationTiming)instantiationTiming
  35. dependencies:(NSArray<FIRDependency *> *)dependencies
  36. creationBlock:(FIRComponentCreationBlock)creationBlock {
  37. return [[FIRComponent alloc] initWithProtocol:protocol
  38. instantiationTiming:instantiationTiming
  39. dependencies:dependencies
  40. creationBlock:creationBlock];
  41. }
  42. - (instancetype)initWithProtocol:(Protocol *)protocol
  43. instantiationTiming:(FIRInstantiationTiming)instantiationTiming
  44. dependencies:(NSArray<FIRDependency *> *)dependencies
  45. creationBlock:(FIRComponentCreationBlock)creationBlock {
  46. self = [super init];
  47. if (self) {
  48. _protocol = protocol;
  49. _instantiationTiming = instantiationTiming;
  50. _dependencies = [dependencies copy];
  51. _creationBlock = creationBlock;
  52. }
  53. return self;
  54. }
  55. @end