javascript - “.then(() => Storage.deployed())”在 Javascript 中的实际含义是什么?
问题描述
我正在学习 Solidity,部署脚本说这样的话,
var Storage = artifacts.require("./Storage.sol");
var InfoManager = artifacts.require("./InfoManager.sol");
module.exports = function(deployer) {
// Deploy the Storage contract
deployer.deploy(Storage)
// Wait until the storage contract is deployed
.then(() => Storage.deployed())
// Deploy the InfoManager contract, while passing the address of the
// Storage contract
.then(() => deployer.deploy(InfoManager, Storage.address));
}
而且我似乎无法谷歌右箭头字符“=>”。
解决方案
() =>
是 Javascript 中的箭头函数。
定义
箭头函数表达式是正则函数表达式的语法紧凑替代方案,尽管它没有绑定到 this、arguments、super 或 new.target 关键字。箭头函数表达式不适合用作方法,它们不能用作构造函数。
.then()
定义:
then() 方法返回一个 Promise。它最多需要两个参数:Promise 成功和失败情况的回调函数。
阅读更多关于 Promise.prototype.then()
发生的事情是,当deployer.deploy(Storage)
promise 解决后,您将函数storage.deployed()
作为回调函数执行。
推荐阅读
- google-chrome - 如何(重新)将浏览器窗口插入 Chromium 的标签栏?
- c# - 成功注册/登录后不显示 LOGOUT 按钮,ASP.NET Core 标识
- typescript - 从通用类型中提取类型或接口名称作为 Typescript 中的字符串
- rendering - 如何修复模糊的 VS2019
- usb - 在 ubuntu 18.04 的某些条件下,用户配置从 70-snap.core.rules 文件中删除
- r - 根据一个变量的值在堆叠条形图中排列堆叠
- sass - 尝试使用新的 @use 语法在 create-react-app 中使用 sass 模块但收到错误
- javascript - setInterval 不是每秒刷新数据
- javascript - 通过 Fetch API 验证登录
- python - 是否可以使用签名的 JWT 对 Google Drive API 进行授权调用?