or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

ai.mdanalytics.mdapp-check.mdauth-guard.mdauthentication.mddata-connect.mddatabase.mdfirebase-app.mdfirestore.mdfunctions.mdindex.mdmessaging.mdperformance.mdremote-config.mdstorage.mdvertexai.md
tile.json

functions.mddocs/

Cloud Functions

Firebase Cloud Functions integration for calling server-side functions directly from Angular applications with automatic serialization and error handling.

Capabilities

Standalone Provider

export function provideFunctions(fn: () => Functions): EnvironmentProviders;
export function getFunctions(app?: FirebaseApp, regionOrCustomDomain?: string): Functions;

Angular Services

export class Functions extends Functions {}
export class FunctionsInstances extends Array<Functions> {}
export const functionInstance$: Observable<Functions>;

Functions Operations

/**
 * Create callable function reference
 * @param functions - Functions instance
 * @param name - Function name
 * @param options - Optional call options
 * @returns Callable function
 */
export function httpsCallable<T = any, R = any>(
  functions: Functions,
  name: string,
  options?: HttpsCallableOptions
): HttpsCallable<T, R>;

/**
 * Connect to Functions emulator
 * @param functions - Functions instance
 * @param host - Emulator host
 * @param port - Emulator port
 */
export function connectFunctionsEmulator(
  functions: Functions,
  host: string,
  port: number
): void;

interface HttpsCallable<T = any, R = any> {
  (data?: T): Promise<HttpsCallableResult<R>>;
}

interface HttpsCallableResult<T = any> {
  readonly data: T;
}

Usage Examples

import { Component, inject } from '@angular/core';
import { Functions, httpsCallable } from '@angular/fire/functions';

@Component({
  selector: 'app-functions',
  template: `...`,
})
export class FunctionsComponent {
  private functions = inject(Functions);

  async processPayment(paymentData: any) {
    const processPaymentFn = httpsCallable(this.functions, 'processPayment');
    
    try {
      const result = await processPaymentFn(paymentData);
      console.log('Payment processed:', result.data);
      return result.data;
    } catch (error) {
      console.error('Payment error:', error);
      throw error;
    }
  }

  async sendNotification(message: string, userId: string) {
    const sendNotificationFn = httpsCallable<{message: string, userId: string}, {success: boolean}>(
      this.functions, 
      'sendNotification'
    );
    
    const result = await sendNotificationFn({ message, userId });
    return result.data.success;
  }
}