@@ -15,7 +15,7 @@ the Interop system. Both SDKs depend on a shared protocol that describes the fun
15
15
by one SDK and required by the other. Let's use ` A ` and ` B ` , where ` B ` depends on functionality
16
16
provided by ` A ` and the functionality is described by protocol ` AInterop ` .
17
17
18
- During configuration, ` A ` tells Core that it provides functionality for ` AInterop ` and ` B ` tells
18
+ During configuration, ` A ` tells Core that it provides functionality for ` AInterop ` and ` B ` tells
19
19
Core it would like functionality ` AInterop ` (and specifies whether it is required or optional) as
20
20
well as how to instantiate an instance of ` B ` . When a developer requests ` B ` , FirebaseCore
21
21
instantiates ` B ` and passes a container that contains the instance of ` A ` that provides ` AInterop ` .
@@ -126,7 +126,7 @@ that it uses to register with the container. Using Functions as an example:
126
126
@implementation FIRFunctions
127
127
128
128
+ (void)load {
129
- [FIRComponentContainer registerAsComponentRegistrant:self];
129
+ [FIRComponentContainer registerAsComponentRegistrant:self];
130
130
}
131
131
132
132
/// The array of components to register with Core. Since Functions is a leaf node and
@@ -146,7 +146,7 @@ that it uses to register with the container. Using Functions as an example:
146
146
};
147
147
148
148
// Create the component that can create instances of `FIRFunctions`.
149
- FIRComponent *internalProvider =
149
+ FIRComponent *internalProvider =
150
150
[FIRComponent componentWithProtocol:@protocol(FIRFunctionsInstanceProvider)
151
151
creationBlock:creationBlock];
152
152
@@ -158,13 +158,13 @@ that it uses to register with the container. Using Functions as an example:
158
158
// Get the instance from the `FIRApp`'s container. This will create a new instance the
159
159
// first time it is called, and since `isCacheable` is set in the component creation
160
160
// block, it will return the existing instance on subsequent calls.
161
- id<FIRFunctionsInstanceProvider> instance =
161
+ id<FIRFunctionsInstanceProvider> instance =
162
162
FIR_COMPONENT(FIRFunctionsInstanceProvider, app.container);
163
163
164
164
// In the component creation block, we return an instance of `FIRFunctions`. Cast it and
165
165
// return it.
166
166
return (FIRFunctions *)instance;
167
- }
167
+ }
168
168
169
169
// ... Other `FIRFunctions` methods.
170
170
@@ -201,7 +201,7 @@ could conform to and provide to other SDKs:
201
201
*isCacheable = YES;
202
202
return [[FIRAuth alloc] initWithApp:container.app];
203
203
};
204
- FIRComponent *authInterop =
204
+ FIRComponent *authInterop =
205
205
[FIRComponent componentWithProtocol:@protocol(FIRAuthInteroperable)
206
206
creationBlock:authCreationBlock];
207
207
return @[authInterop];
@@ -264,7 +264,7 @@ separate class to keep `Firestore.m` cleaner.
264
264
265
265
+ (void)load {
266
266
// Don't forget to register!
267
- [FIRComponentContainer registerAsComponentRegistrant:self];
267
+ [FIRComponentContainer registerAsComponentRegistrant:self];
268
268
}
269
269
270
270
- (instancetype)initWithApp:(FIRApp *)app {
@@ -332,12 +332,12 @@ Before adding the dependency on `FIRAuthInterop`.
332
332
return [[FIRFunctions alloc] initWithApp:container.app];
333
333
};
334
334
335
- FIRComponent *internalProvider =
335
+ FIRComponent *internalProvider =
336
336
[FIRComponent componentWithProtocol:@protocol(FIRFunctionsInstanceProvider)
337
337
creationBlock:creationBlock];
338
338
339
339
return @[ internalProvider ];
340
- }
340
+ }
341
341
```
342
342
343
343
After adding the dependency on ` FIRAuthInterop ` . See comments with "ADDED:".
@@ -350,7 +350,7 @@ After adding the dependency on `FIRAuthInterop`. See comments with "ADDED:".
350
350
351
351
// ADDED: Retrieve an instance that conforms to `FIRAuthInterop` from the container.
352
352
id<FIRAuthInterop> auth = FIR_COMPONENT(FIRAuthInterop, container);
353
-
353
+
354
354
// ADDED: Note the constructor has a new parameter: auth. It's good practice to inject
355
355
// the instance needed in the constructor instead of pulling it from the app
356
356
// passed in. This allows for better unit testing with fakes since any object
@@ -360,7 +360,7 @@ After adding the dependency on `FIRAuthInterop`. See comments with "ADDED:".
360
360
361
361
// ADDED: Define a dependency on the `FIRAuthInteroperable` protocol. Declare if the
362
362
// dependency is required or not.
363
- FIRDependency *auth =
363
+ FIRDependency *auth =
364
364
[FIRDependency dependencyWithProtocol:@protocol(FIRAuthInteroperable)
365
365
isRequired:NO];
366
366
@@ -376,7 +376,7 @@ After adding the dependency on `FIRAuthInterop`. See comments with "ADDED:".
376
376
creationBlock:creationBlock];
377
377
378
378
return @[ internalProvider ];
379
- }
379
+ }
380
380
```
381
381
382
382
Based on the new constructor, Functions can now use the ` auth ` instance as defined by the
@@ -420,7 +420,7 @@ An abbreviated code sample:
420
420
};
421
421
422
422
// Declare a self dependency on the combined interop component.
423
- FIRDependency *auth =
423
+ FIRDependency *auth =
424
424
[FIRDependency dependencyWithProtocol:@protocol(FIRAuthCombinedInterop)
425
425
isRequired:YES];
426
426
@@ -431,19 +431,19 @@ An abbreviated code sample:
431
431
432
432
// Both the user and sign in components depend on the previous component as
433
433
// declared in the dependency above.
434
-
434
+
435
435
FIRComponent *userComponent =
436
436
[FIRComponent componentWithProtocol:@protocol(FIRAuthUserInterop)
437
437
instantiationTiming:FIRInstantiationTimingLazy
438
438
dependencies:@[ auth ]
439
439
creationBlock:combinedBlock];
440
-
440
+
441
441
FIRComponent *signInComponent =
442
442
[FIRComponent componentWithProtocol:@protocol(FIRAuthSignInInterop)
443
443
instantiationTiming:FIRInstantiationTimingLazy
444
444
dependencies:@[ auth ]
445
445
creationBlock:combinedBlock];
446
446
447
447
return @[ authComponent, userComponent, signInComponent ];
448
- }
448
+ }
449
449
```
0 commit comments