Skip to content
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

cloud function with angularfire2 #856

Closed
johnqiuwan opened this issue Mar 13, 2017 · 10 comments
Closed

cloud function with angularfire2 #856

johnqiuwan opened this issue Mar 13, 2017 · 10 comments

Comments

@johnqiuwan
Copy link

Hi Guys,

I am very excited that the cloud function is working with firebase now !

Just a quick question, does anyone know if angularfire2 support cloud function or we need to use firebase sdk to work with cloud function for now?

Thank you

@frankspin89
Copy link

You have to use the Firebase CLI to deploy your functions to Firebase. Cloud functions are backend related, not frontend.

As far as I know AngularFire is not related to Cloud Functions

@davideast
Copy link
Member

@johnqiuwan Server events are triggered by events. @frankspin89 is right in saying we don't have any direct integrations.

@johnqiuwan
Copy link
Author

Thank you @davideast and @frankspin89

If I understand correct, we need to use raw firebase sdk to implement cloud functions.

@johanchouquet
Copy link
Contributor

Hi there,

I understand that AngularFire2 is for Frontend purposes, and Cloud Functions are for backend, but it'd be nice to be able to rely on 1 single API (ie AngularFire2) when starting on a new Angular Firebase Project.
It's a bit a pain to have to re-learn every little thing and different detail from one API to another when a dev has to work on Functions, while he knows quite a lot with AngularFire2 API.

I think it'd be great to be able to use AngularFire2 API to fetch data for example, inside a Function, instead of using firebase-admin, by doing admin.firebase().ref(...). The documentation is also different from AngularFire2, with sometimes differences in terms of updates...

As of today, are there any plans to support writing Functions extending AngularFire2 ?

@nogtini
Copy link

nogtini commented Apr 11, 2018

I'd agree with @johanchouquet , especially since much of angularfire is a lightweight wrapper over firebase's rest api, incorporating a simple fetch utility for "cloud function"-specific restful requests might prove useful.

@davideast
Copy link
Member

@johanchouquet @yejodido Cloud Functions recently implemented a client SDK for "callable functions" and we have a PR #1532 to support it. So follow that and wait just a little longer.

@Mercieral
Copy link

Mercieral commented Apr 25, 2018

Any update on when we can expect this PR? I'm hoping with PR #1532 that I will be able to use an angularfire2 wrapper for callable functions and not have to deal with the issue below.

Currently trying to work around it, but I am getting ERROR in <filename hidden>: error TS2339: Property 'functions' does not exist on type 'typeof firebase'.
when trying to import firebase modules directly based on their docs. Strangely enough it will fail to compile the first time, but if I make any changes that causes it to recompile it works fine (meaning I can develop kindof but cannot deploy).

import * as firebase from 'firebase';

// Required for side-effects
import 'firebase/functions';

const createGame = firebase.functions().httpsCallable('myCallableFunction');

UPDATE: For those doing the same thing I am doing, wrapping firebase in an object fixes my problem ... Object(firebase).functions()...for now so I am not depending on this PR anymore. I'm still looking forward to it though!

@fullstackduck
Copy link

fullstackduck commented May 7, 2018

@Mercieral whenever you get anything like Property 'functions' does not exist on type 'typeof firebase'

you can just cast it as any, so
const createGame = (firebase as any).functions().httpsCallable('myCallableFunction');
would work too.
I believe it's actually better way to do it anyways

:)

@Tristan10
Copy link

I see that PR #1532 has been accepted. Are there any examples on how to use this? I tried using like in the firebase docs but I end up with "Object is not a function" error.

@khalilchoudhry
Copy link

@Tristan10 have you found any examples?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants