#functions call from library

2 messages · Page 1 of 1 (latest)

calm crypt
#
import { AngularFireAuth } from '@angular/fire/compat/auth';
import { SignupModel } from '../../models/signup.model';
import { from, Observable } from 'rxjs';
import { Functions } from '@angular/fire/functions';
import { FireBaseAuthprovider } from '@karma/ngx-sg';

@Injectable({
  providedIn: 'root',
})
export class SignupService {
  fireAuth = inject(AngularFireAuth);
  AuthProvider = inject(FireBaseAuthprovider);
  private functions: Functions = inject(Functions);

  signupWithEmailAndPassword(signup: SignupModel): Observable<void> {
    return from(this.AuthProvider.createUserWithEmailAndPassword(signup));
  }

  private async refreshToken(): Promise<void> {
    const user = await this.fireAuth.currentUser;
    await user?.getIdTokenResult(true);
  }
}
@Injectable()
export class FireBaseAuthprovider extends Authprovider {
 @Output() setInitClameFunctionName!: string;
 private auth: Auth = inject(Auth);
 private functions: Functions = inject(Functions);
 fireFunction = inject(AngularFireFunctions);

 override signInWithEmailAndPassword(
   email: string,
   password: string
 ): Observable<void> {
   return from(signInWithEmailAndPassword(this.auth, email, password)).pipe(
     mergeMap(() => this.refreshToken())
   );
 }

 override createUserWithEmailAndPassword(
   data: signupEntity
 ): Observable<void> {
   return from(
     createUserWithEmailAndPassword(this.auth, data.email, data.password)
   )
     .pipe(mergeMap(() => this.updateUserDisplayNameAndClaims(data)))
     .pipe(mergeMap(() => this.refreshToken()));
 }
} ```

the first code is the service from my project
and the second code is file that contains some auth functions  that i wrote in my library 

i did that so i don't have to repeat it everytime
the only issue now 
how can i call these functions into the service
lyric spindle
#

You're already doing it: you inject the service into your other service. Note that Outputs in a service don't make sense though.