We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
c#调用js回调后,如果触发promise的resolve,promise的后续会晚一帧,如果c#在回调后清理数据,js promise拿到的就是错误数据。 有什么好的办法吗
//这部分是C#代码 class TestData{ public int value; } class TestClass{ private Action<TestData> _onDone; void SetOnDone(Action<TestData> v){ _onDone = v; //通过协程或者update 实现1s后调用WhenDone } void WhenDone(){ TestData data = MyPool.get<TestData>(); //从对象池获取一个TestData data.value = 999; //设置想要的值 _onDone(data); //归还给对象池 data.value = 0; MyPool.despawn(data); } }
//这部分是js代码 class JsClass { getData() { let testClass = new TestClass() // get TestClass return new Promise((resolve, reject) => { testClass.SetOnDone((ret) => { resolve(ret) }) }) } async testData() { let data = await this.getData() // 下面这行 puerts-webgl下会输出0 ,puets v8版 会输出999 console.log("data.value:", data.value) } } (new JsClass).testData()
The text was updated successfully, but these errors were encountered:
如果其中一方是浏览器,理论上应该以浏览器为准。应该从puerts native层面修
Sorry, something went wrong.
No branches or pull requests
c#调用js回调后,如果触发promise的resolve,promise的后续会晚一帧,如果c#在回调后清理数据,js promise拿到的就是错误数据。
有什么好的办法吗
The text was updated successfully, but these errors were encountered: