CloudFunctions.getHttpsCallable参数 [英] CloudFunctions.getHttpsCallable parameters

查看:58
本文介绍了CloudFunctions.getHttpsCallable参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因为Flutter的0.2.0 cloud_functions版本使用.getHttpsCallable()而不是.call().新方法定义为:

Since the version 0.2.0 cloud_functions for Flutter use .getHttpsCallable() instead of .call(). The new method is defined as:

/// @param functionName The name of the callable function being triggered.
/// @param parameters Parameters to be passed to the callable function.
HttpsCallable getHttpsCallable(
    {@required String functionName, Map<String, dynamic> parameters}) {
  return HttpsCallable._(this, functionName);
}

如我们所见,虽然声明并记录了参数,但并未使用参数parameters(我在调试应用程序时学到了这道难题.)因此,人们希望将参数传递给参数parameters到后续的.call().可调用对象.为何为新方法声明该参数的原因是什么?

As we can see, the argument parameters is not used though declared and documented (I learned it the hard way while debugging the app.) So, one is expected to pass the parameters to the subsequent .call() on the callable object. What's the reason why the argument is declared for the new method at all?

推荐答案

尽管我无法解释为什么采用这种方式设计,但有些人可能会发现本文使用getHttpsCallable函数寻求帮助.这是一个调用名为addUser的云函数的示例,该函数具有两个参数,电子邮件和密码.这些参数通常可以通过其他方式定义,例如通过TextController的text属性定义.

Although I can't explain why it was designed this way, some people might find this post looking for help using the getHttpsCallable function. Here is an example calling a cloud function called addUser with two parameters, email and password. These parameters would normally be defined in another way such as via the text property of a TextController.

CloudFunctions.instance.getHttpsCallable(
                          functionName: "addUser",
                      ).call(
                          <String, dynamic>{
                            "email": "test@test.com",
                            "password": "Terrific password!"
                          },
                      );

这篇关于CloudFunctions.getHttpsCallable参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆