Skip to content

Commit b2ba185

Browse files
committed
Renamed SDKs to frameworks and products for accuracy.
1 parent c8c7a04 commit b2ba185

File tree

1 file changed

+49
-45
lines changed

1 file changed

+49
-45
lines changed

Interop/Firebase Component System.md

Lines changed: 49 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# Using Core's Component System
22

33
FirebaseCore has a dependency injection system (referred to as "Interop") used to depend on
4-
functionalities provided by other Firebase SDKs. This gives the ability to depend on a typesafe
5-
interface-only API to consume without depending on the entire SDK and simulates optional
6-
dependencies - depending on the definition but not the implementing SDK and only functioning when
7-
the implementing SDK is included.
4+
functionalities provided by other Firebase products (specifically, the frameworks that offer those
5+
products). This gives the ability to depend on a typesafe interface-only API to consume without
6+
depending on the entire product and simulates optional dependencies - depending on the definition
7+
but not the product itself and only functioning when the product implementing that definition is
8+
included.
89

910
## Table of Contents
1011

@@ -14,20 +15,21 @@ the implementing SDK is included.
1415
- [Registering with Core](#registering-with-core)
1516
- [Singletons and Instance Management](#singletons-and-instance-management)
1617
- [Single Instance per `FIRApp`](#single-instance-per-firapp)
17-
- [SDK does not provide functionality (example: Functions)](#sdk-does-not-provide-functionality-(example:-functions))
18-
- [SDK provides functionality to other SDKs (example: Auth)](#sdk-provides-functionality-to-other-SDKs-(example:-auth))
18+
- [Framework does not provide functionality (example: Functions)](#framework-does-not-provide-functionality-(example:-functions))
19+
- [Framework provides functionality to other Frameworks (example: Auth)](#framework-provides-functionality-to-other-frameworks-(example:-auth))
1920
- [Multiple Instances per FIRApp](#multiple-instances-per-firapp)
20-
- [Depending on Functionality from Another SDK](#depending-on-functionality-from-another-sdk)
21+
- [Depending on Functionality from Another Framework](#depending-on-functionality-from-another-framework)
2122
- [Advanced Use Cases](#advanced-use-cases)
2223
- [Providing Multiple Components and Sharing Instances](#providing-multiple-components-and-sharing-instances)
2324

2425

2526
## Overview
2627

27-
When a Firebase SDK wants to provide functionality to another Firebase SDK, it must be done through
28-
the Interop system. Both SDKs depend on a shared protocol that describes the functionality provided
29-
by one SDK and required by the other. Let's use `A` and `B`, where `B` depends on functionality
30-
provided by `A` and the functionality is described by protocol `AInterop`.
28+
When a Firebase framework wants to provide functionality to another Firebase framework, it must be
29+
done through the Interop system. Both frameworks depend on a shared protocol in a separate framework
30+
that describes the functionality provided by one framework and required by the other. Let's use `A`
31+
and `B`, where `B` depends on functionality provided by `A` and the functionality is described by
32+
protocol `AInterop`.
3133

3234
During configuration, `A` tells Core that it provides functionality for `AInterop` and `B` tells
3335
Core it would like functionality `AInterop` (and specifies whether it is required or optional) as
@@ -37,44 +39,45 @@ instantiates `B` and passes a container that contains the instance of `A` that p
3739
`B` has no idea what class `A` is, and it doesn't need to. All `B` needs to know is that it has an
3840
instance of an object that conforms to `AInterop` and provides the functionality it needs.
3941

40-
This system allows Firebase SDKs to depend on each other in a typesafe way and allows us to
41-
explicitly declare version dependencies on the interfaces required instead of the SDK version.
42+
This system allows Firebase frameworks to depend on each other in a typesafe way and allows us to
43+
explicitly declare version dependencies on the interfaces required instead of the product's version.
4244

4345
## Protocol Only Frameworks
4446

45-
In order to share protocols between two SDKs, we introduced header only frameworks that declare the
46-
desired protocol(s).
47+
In order to share protocols between two frameworks, we introduced header only frameworks that
48+
declare the desired protocol(s).
4749

48-
The naming convention for the framework should be `<SDKName>Interop` but the protocols don't have a
49-
strict naming guideline other than having a `FIR` prefix in Objective-C.
50+
The naming convention for the framework should be `<ProductName>Interop` but the protocols don't
51+
have a strict naming guideline other than having a `FIR` prefix in Objective-C.
5052

51-
Both the implementing and dependent SDK will have a required dependency on this `<SDKName>Interop`
52-
framework: the implementing SDK must conform to the protocols defined and register it with Core,
53-
while the dependent SDK will use the protocol definition to use methods defined by it.
53+
Both the implementing and dependent framework will have a required dependency on this
54+
`<ProductName>Interop` framework: the implementing framework must conform to the protocols defined
55+
and register it with Core, while the dependent framework will use the protocol definition to use
56+
methods defined by it.
5457

55-
An Interop framework can have multiple protocols, but all should be implemented by the SDK it is
56-
named after.
58+
An Interop framework can have multiple protocols, but all should be implemented by the product it
59+
is named after.
5760

5861
Protocols *can not* declare class methods. This is an intentional decision to ensure all interfaces
5962
interact properly based on the `FIRApp` that's used.
6063

6164
## Types and Core API
6265

6366
For the rest of the documentation, it's important to be familiar with the various classes and API
64-
provided by Core. Since the SDKs are written in Objective-C, we'll use the Objective-C names. The
65-
Swift names are identical but dropping the `FIR` prefix.
67+
provided by Core. Since the frameworks are written in Objective-C, we'll use the Objective-C names.
68+
The Swift names are identical but dropping the `FIR` prefix.
6669

6770
- `@class FIRDependency`
6871
- A dependency on a specific protocol's functionality. Created with the factory method
6972
`[FIRDependency dependencyWithProtocol:isRequired:]`
7073
- `@class FIRComponent`
71-
- A component to register with Core to be consumed by other SDKs. It declares the protocol
74+
- A component to register with Core to be consumed by other frameworks. It declares the protocol
7275
offered, dependencies, and a block for Core to instantiate it.
7376
- `@class FIRComponentContainer`
7477
- A container that holds different components that are registered with Core.
7578
- `@protocol FIRComponentRegistrant`
76-
- Describes functionality for SDKs registering components in the `FIRComponentContainer`. It
77-
allows Core to fetch components lazily from the SDK.
79+
- Describes functionality for frameworks registering components in the `FIRComponentContainer`. It
80+
allows Core to fetch components lazily from the implementing framework.
7881
- `#define FIR_COMPONENT(protocol, container)` (macro)
7982
- The macro to request an instance conforming to a given protocol from a container. Due to
8083
Objective-C's lightweight generic system, the safest and most readable API is provided by a
@@ -83,7 +86,7 @@ Swift names are identical but dropping the `FIR` prefix.
8386

8487
## Registering with Core
8588

86-
Each Firebase SDK should register with Core in the `+load` method of the class conforming to
89+
Each Firebase framework should register with Core in the `+load` method of the class conforming to
8790
`FIRComponentRegistrant`. This needs to happen at `+load` time because Core needs to resolve any
8891
dependencies before a class has a chance to be called by a developer (if called at all).
8992

@@ -108,23 +111,24 @@ dependencies before a class has a chance to be called by a developer (if called
108111

109112
### Singletons and Instance Management
110113

111-
All Firebase SDKs provide singleton access for convenience that map to a specific `FIRApp`:
112-
`[FIRAuth auth]`, `[FIRFunctions functionsForApp:]`, etc. Some SDKs can also have multiple instances
113-
per `FIRApp` such as Storage: `[FIRStorage storageForApp:URL:]`.
114+
All Firebase frameworks provide singleton access for convenience that map to a specific `FIRApp`:
115+
`[FIRAuth auth]`, `[FIRFunctions functionsForApp:]`, etc. Some frameworks can also have multiple
116+
instances per `FIRApp` such as Storage: `[FIRStorage storageForApp:URL:]`.
114117

115118
These instances must be created and managed by Core through the component system. This allows the
116119
`FIRApp` lifecycle to control the lifecycle of instances associated with itself. There are different
117-
ways to do so depending on the SDK's situation.
120+
ways to do so depending on the product's offerings.
118121

119122
#### Single Instance per `FIRApp`
120123

121-
The registration for a single instance per `FIRApp` changes if the SDK provides functionality to
122-
other SDKs or not.
124+
The registration for a single instance per `FIRApp` changes if the framwork provides functionality
125+
to other frameworks or not.
123126

124-
##### SDK does not provide functionality (example: Functions)
127+
##### Framework does not provide functionality (example: Functions)
125128

126-
In this case, the SDK is a "leaf node" since no SDKs depend on it. It has a private, empty protocol
127-
that it uses to register with the container. Using Functions as an example:
129+
In this case, the framework is a "leaf node" since no other frameworks depend on functionality from
130+
it. It has a private, empty protocol that it uses to register with the container. Using Functions as
131+
an example:
128132

129133
```
130134
// FIRFunctions.h
@@ -144,7 +148,7 @@ that it uses to register with the container. Using Functions as an example:
144148
}
145149
146150
/// The array of components to register with Core. Since Functions is a leaf node and
147-
/// doesn't provide any functionality to other SDKs, it should use Core for instance
151+
/// doesn't provide any functionality to other frameworks, it should use Core for instance
148152
/// management only.
149153
+ (NSArray<FIRComponent *> *)componentsToRegister {
150154
// Each component needs a block for Core to call in order to instantiate instances of the
@@ -185,10 +189,10 @@ that it uses to register with the container. Using Functions as an example:
185189
@end
186190
```
187191

188-
##### SDK provides functionality to other SDKs (example: Auth)
192+
##### Framework provides functionality to other Frameworks (example: Auth)
189193

190194
This example will be very similar to the one above, but let's define a simple protocol that Auth
191-
could conform to and provide to other SDKs:
195+
could conform to and provide to other frameworks:
192196

193197
```
194198
// FIRAuthInterop.h in the FirebaseAuthInterop framework.
@@ -230,7 +234,7 @@ could conform to and provide to other SDKs:
230234

231235
#### Multiple Instances per `FIRApp`
232236

233-
Instead of directly providing an instance from the container, Firestore and similar SDKs should
237+
Instead of directly providing an instance from the container, Firestore and similar products should
234238
create a "provider" that stores and creates instances with the required parameters. This means a
235239
single provider per `FIRApp`, but multiple instances are possible per provider.
236240

@@ -325,16 +329,16 @@ All `Firestore.m` needs to do now is call the component container from the singl
325329
}
326330
```
327331

328-
### Depending on Functionality from Another SDK
332+
### Depending on Functionality from Another Framework
329333

330334
*If you haven't already read [Registering with Core](#registering-with-core), please do so until you
331335
get back to this spot as it lays the groundwork necessary to understand this section.*
332336

333337
Adding dependencies is easy once components are registered with Core. Let's take the example from
334338
Functions above and add a dependency to `FIRAuthInterop` defined above.
335339

336-
**Important**: You will also need to add a dependency on the `FirebaseAuthInterop` pod to your SDK's
337-
podspec and any package manager supported.
340+
**Important**: You will also need to add a dependency on the `FirebaseAuthInterop` pod to your
341+
product's podspec and any package manager supported.
338342

339343
Before adding the dependency on `FIRAuthInterop`.
340344

@@ -407,7 +411,7 @@ if (userID) {
407411

408412
### Providing Multiple Components and Sharing Instances
409413

410-
Consider a situation where an SDK wants to offer functionality defined in multiple protocols
414+
Consider a situation where a framework wants to offer functionality defined in multiple protocols
411415
with the same instance. For example, Auth could provide `FIRAuthUserInterop` and
412416
`FIRAuthSignInInterop`. If a single Auth instance should be shared between those two protocols, the
413417
system currently doesn't work.

0 commit comments

Comments
 (0)