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

NasExtWallet.getUserAddress() 在单个通信周期内只能承载一个回调 #40

Open
cssmagic opened this issue Sep 3, 2018 · 1 comment

Comments

@cssmagic
Copy link

cssmagic commented Sep 3, 2018

我只是在测试中发现了一个现象,暂时没有深入阅读钱包扩展的源码。

在每个交互周期内(页面 → 钱包扩展 → 页面),NasExtWallet.getUserAddress() 方法只能承载一个回调。也就是说,连续多次调用 NasExtWallet.getUserAddress(callback),最后一次注册的 callback 会覆盖之前的所有 callback。

比如有以下代码:

NasExtWallet.getUserAddress(function () {
	console.log(1)
})
NasExtWallet.getUserAddress(function () {
	console.log(2)
})
NasExtWallet.getUserAddress(function () {
	console.log(3)
})
NasExtWallet.getUserAddress(function () {
	console.log(4)
})

会在控制台得到 4 4 4 4,而不是 1 2 3 4


Original issue: NasaTeam/Nasa.js#31

@cssmagic
Copy link
Author

cssmagic commented Sep 3, 2018

这是一个比较边缘的情况,遇到的概率可能不大,不过最好还是能修一下。

这个 bug 在一定程度上也说明异步通信可能比我们想像得要复杂。因此还是希望钱包扩展与页面的通信机制能修改( #38 ),这样对于扩展的开发者和 DApp 的开发者来说,都是成本的降低。

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

1 participant