/// <summary> /// Resolve the linked <see cref="Promises.Promise"/>. /// </summary> public void Resolve() { if (!IsValid) { throw new InvalidOperationException("Deferred.Resolve: instance is not valid.", Internal.GetFormattedStacktrace(1)); } var promise = Promise; ValidateOperation(promise, 1); if (State == State.Pending) { Promise.CancelCallbacks(); promise.ResolveDirect(); } else { Manager.LogWarning("Deferred.Resolve - Deferred is not in the pending state."); return; } }
/// <summary> /// Reject the linked <see cref="Promises.Promise"/> with <paramref name="reason"/>. /// </summary> public void Reject <TReject>(TReject reason) { if (!IsValid) { throw new InvalidOperationException("Deferred.Reject: instance is not valid.", Internal.GetFormattedStacktrace(1)); } var promise = Promise; ValidateOperation(promise, 1); if (State == State.Pending) { Promise.CancelCallbacks(); promise.RejectDirect(ref reason, 1); } else { Internal.AddRejectionToUnhandledStack(reason, null); Manager.LogWarning("Deferred.Reject - Deferred is not in the pending state."); } }