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