示例#1
0
        IEnumerator update <T>(PromiseWithHandler <T> p)
        {
            while (true)
            {
                if (p.onProgressed != null)
                {
                    if (p.promise.progress != p.previousProgress)
                    {
                        p.previousProgress = p.promise.progress;
                        p.onProgressed(p.promise.progress);
                    }
                }

                if (p.promise.state == PromiseState.Fulfilled)
                {
                    if (p.onFulfilled != null)
                    {
                        p.onFulfilled(p.promise.result);
                    }
                    _promises--;
                    updateName();
                    yield break;
                }

                if (p.promise.state == PromiseState.Failed)
                {
                    if (p.onFailed != null)
                    {
                        p.onFailed(p.promise.error);
                    }
                    _promises--;
                    updateName();
                    yield break;
                }

                yield return(new WaitForEndOfFrame());
            }
        }
示例#2
0
 void addPromiseWithHandler <T>(PromiseWithHandler <T> promiseWithHandler)
 {
     _promises++;
     updateName();
     StartCoroutine(update(promiseWithHandler));
 }