-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
feat(functions): Adding AngularFireFunctions with httpCallable #1532
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good @jamesdaniels! Just a few comments about new RxJS import paths and using pipeable operators.
src/functions/functions.ts
Outdated
|
||
import { FirebaseAppConfig, FirebaseAppName, _firebaseAppFactory, FirebaseZoneScheduler } from 'angularfire2'; | ||
|
||
import 'rxjs/add/observable/fromPromise'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure to use pipeable operators.
src/functions/functions.ts
Outdated
const callable = this.functions.httpsCallable(name); | ||
return (data: T) => { | ||
return this.scheduler.runOutsideAngular( | ||
Observable.fromPromise(callable(data)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use import { from } from 'rxjs/observable/from';
. It also works with promises. Then use the rxjs/operators
specifier to import the pipeable operators.
import { from } from 'rxjs/observable/from';
import { map } from 'rxjs/operators';
from(promise).pipe(
map(() => {})
);
src/functions/functions.ts
Outdated
} | ||
} | ||
|
||
constructor( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit. Bring the constructor above the method above.
src/functions/functions.ts
Outdated
import { FirebaseFunctions, HttpsCallableResult } from '@firebase/functions-types'; | ||
import { FirebaseOptions } from '@firebase/app-types'; | ||
import { Injectable, Inject, Optional, NgZone } from '@angular/core'; | ||
import { Observable } from 'rxjs/Observable'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can now just do
import { Observable } from 'rxjs';
src/functions/functions.ts
Outdated
return (data: T) => { | ||
return this.scheduler.runOutsideAngular( | ||
Observable.fromPromise(callable(data)) | ||
.map(r => r.data as R) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davideast what do you think about mapping .data
here? This is the only thing I'm on the fence about. It's nice ergo buuut what if the CF3 team decides to pass more than .data
back at some point? That would force an API break.
Appreciate the review, I'll jump on these after addressing the Firebase SDK stuff. |
@davideast addressed your review and updated against master. |
Checklist
yarn install
,yarn test
run successfully? (yes/no; required)Description
Code sample