MCPcopy Create free account
hub / github.com/angular/dev-infra / asCallable

Method asCallable

apps/code-of-conduct/app/block.service.ts:81–100  ·  view source on GitHub ↗

* Helper function to create a callable function that automatically refreshes the blocked users list. * @param callableName The name of the callable function to create. * @returns A function that can be called to invoke the callable function.

(
    callableName: string,
    skipRefresh = false,
  )

Source from the content-addressed store, hash-verified

79 * @returns A function that can be called to invoke the callable function.
80 */
81 private asCallable<T, R>(
82 callableName: string,
83 skipRefresh = false,
84 ): (callableArg: T) => Promise<R> {
85 return async (callableArg: T) => {
86 try {
87 const result = await httpsCallable<T, R>(this.functions, callableName)(callableArg);
88 if (!skipRefresh) {
89 this.refreshBlockedUsers$.next();
90 }
91 return result.data;
92 } catch (error) {
93 const message = error instanceof Error ? error.message : 'Unknown error';
94 this.snackBar.open(`Failed to execute ${callableName}: ${message}`, 'Dismiss', {
95 duration: 5000,
96 });
97 throw error;
98 }
99 };
100 }
101}

Callers 1

BlockServiceClass · 0.95

Calls 2

nextMethod · 0.45
openMethod · 0.45

Tested by

no test coverage detected