浏览代码

fix promise to be async.

/main
kg 6 年前
当前提交
ef8e730f
共有 2 个文件被更改,包括 19 次插入14 次删除
  1. 18
      Runtime/promise/Promise.cs
  2. 15
      Runtime/promise/Promise_NonGeneric.cs

18
Runtime/promise/Promise.cs


using System.Collections.Generic;
using System.Linq;
using RSG.Exceptions;
using Unity.UIWidgets.ui;
namespace RSG
{

/// </summary>
private void ActionHandlers(IRejectable resultPromise, Action<PromisedT> resolveHandler, Action<Exception> rejectHandler)
{
if (CurState == PromiseState.Resolved)
{
InvokeHandler(resolveHandler, resultPromise, resolveValue);
if (CurState == PromiseState.Resolved) {
Window.instance.scheduleMicrotask(() => {
InvokeHandler(resolveHandler, resultPromise, resolveValue);
});
else if (CurState == PromiseState.Rejected)
{
InvokeHandler(rejectHandler, resultPromise, rejectionException);
else if (CurState == PromiseState.Rejected) {
Window.instance.scheduleMicrotask(() => {
InvokeHandler(rejectHandler, resultPromise, rejectionException);
});
else
{
else {
AddResolveHandler(resolveHandler, resultPromise);
AddRejectHandler(rejectHandler, resultPromise);
}

15
Runtime/promise/Promise_NonGeneric.cs


using System.Collections.Generic;
using System.Linq;
using RSG.Exceptions;
using Unity.UIWidgets.ui;
namespace RSG
{

/// </summary>
private void ActionHandlers(IRejectable resultPromise, Action resolveHandler, Action<Exception> rejectHandler)
{
if (CurState == PromiseState.Resolved)
{
InvokeResolveHandler(resolveHandler, resultPromise);
if (CurState == PromiseState.Resolved) {
Window.instance.scheduleMicrotask(() => {
InvokeResolveHandler(resolveHandler, resultPromise);
});
else if (CurState == PromiseState.Rejected)
{
InvokeRejectHandler(rejectHandler, resultPromise, rejectionException);
else if (CurState == PromiseState.Rejected) {
Window.instance.scheduleMicrotask(() => {
InvokeRejectHandler(rejectHandler, resultPromise, rejectionException);
});
}
else
{

正在加载...
取消
保存