Skip to content

Update functions-compat for new InstanceFactory #4638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages-exp/functions-compat/src/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ import {
Component,
ComponentType,
InstanceFactory,
ComponentContainer
ComponentContainer,
InstanceFactoryOptions
} from '@firebase/component';
import { Functions as FunctionsServiceExp } from '@firebase/functions-exp';

const DEFAULT_REGION = 'us-central1';

declare module '@firebase/component' {
interface NameServiceMapping {
'app-compat': FirebaseApp;
Expand All @@ -38,14 +41,14 @@ declare module '@firebase/component' {

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

return new FunctionsService(app, functionsServiceExp);
Expand Down
2 changes: 0 additions & 2 deletions packages-exp/functions-exp/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import {
} from '@firebase/component';
import { FUNCTIONS_TYPE } from './constants';

export const DEFAULT_REGION = 'us-central1';

export function registerFunctions(fetchImpl: typeof fetch): void {
const factory: InstanceFactory<'functions'> = (
container: ComponentContainer,
Expand Down