【发布时间】:2019-02-09 23:29:09
【问题描述】:
我参考了 ionic 网站上的 this 文档,以将 firebase 与我的移动应用程序集成。
this.firebase.getToken()
.then(token => console.log(`The token is ${token}`)) // save the token server-side and use it to push notifications to this device
.catch(error => console.error('Error getting token', error));
this.firebase.onTokenRefresh()
.subscribe((token: string) => console.log(`Got a new token ${token}`));
从上面的代码中可以看出,'then'、'catch' 和'subscribe' 方法似乎有一个变量后跟"=>" 符号。这个符号是否具有一般含义,还是因方法而异?究竟是什么意思?
编辑:由于这个问题被其他人标记为重复,我认为这是我不知道的打字稿中的一个新功能。在 JavaScript 中,我一直使用答案之一中指出的老式方法。不过,它可能会帮助像我这样的其他人。
【问题讨论】:
标签: javascript android angular typescript ionic-framework