Skip to content

Commit

Permalink
Make options to factory optional.
Browse files Browse the repository at this point in the history
  • Loading branch information
hsubox76 committed Mar 15, 2021
1 parent 0453815 commit fa26bb1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
5 changes: 3 additions & 2 deletions packages-exp/functions-compat/src/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ declare module '@firebase/component' {

const factory: InstanceFactory<'functions-compat'> = (
container: ComponentContainer,
{ instanceIdentifier: regionOrCustomDomain }: InstanceFactoryOptions
options?: InstanceFactoryOptions
) => {
// Dependencies
const app = container.getProvider('app-compat').getImmediate();
const functionsServiceExp = container
.getProvider('functions-exp')
.getImmediate({
identifier: regionOrCustomDomain
// This value is used as regionOrCustomDomain
identifier: options?.instanceIdentifier
});

return new FunctionsService(app, functionsServiceExp);
Expand Down
8 changes: 5 additions & 3 deletions packages-exp/functions-exp/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import {
Component,
ComponentType,
ComponentContainer,
InstanceFactory
InstanceFactory,
InstanceFactoryOptions
} from '@firebase/component';
import { FUNCTIONS_TYPE } from './constants';

Expand All @@ -30,7 +31,7 @@ export const DEFAULT_REGION = 'us-central1';
export function registerFunctions(fetchImpl: typeof fetch): void {
const factory: InstanceFactory<'functions'> = (
container: ComponentContainer,
{ instanceIdentifier: regionOrCustomDomain }
options?: InstanceFactoryOptions
) => {
// Dependencies
const app = container.getProvider('app-exp').getImmediate();
Expand All @@ -42,7 +43,8 @@ export function registerFunctions(fetchImpl: typeof fetch): void {
app,
authProvider,
messagingProvider,
regionOrCustomDomain,
// regionOrCustomDomain
options?.instanceIdentifier,
fetchImpl
);
};
Expand Down
5 changes: 3 additions & 2 deletions packages/functions/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function registerFunctions(

function factory(
container: ComponentContainer,
{ instanceIdentifier: regionOrCustomDomain }: InstanceFactoryOptions
options?: InstanceFactoryOptions
): Service {
// Dependencies
const app = container.getProvider('app').getImmediate();
Expand All @@ -52,7 +52,8 @@ export function registerFunctions(
app,
authProvider,
messagingProvider,
regionOrCustomDomain,
// regionOrCustomDomain
options?.instanceIdentifier,
fetchImpl
);
}
Expand Down

0 comments on commit fa26bb1

Please sign in to comment.