view Implab/IPromise.cs @ 247:fb70574741a1 v3

working on promises
author cin
date Fri, 26 Jan 2018 18:46:27 +0300
parents eee3e49dd1ff
children
line wrap: on
line source

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Implab {
    public interface IPromise {

        /// <summary>
        /// Тип результата, получаемого через данное обещание.
        /// </summary>
        Type ResultType { get; }

        /// <summary>
        /// Обещание является выполненым, либо успешно, либо с ошибкой, либо отменено.
        /// </summary>
        bool IsResolved { get; }

        bool IsRejected { get; }

        bool IsFulfilled { get; }

        /// <summary>
        /// Исключение возникшее в результате выполнения обещания, либо причина отмены.
        /// </summary>
        Exception RejectReason { get; }

        /// <summary>
        /// Adds specified listeners to the current promise.
        /// </summary>
        /// <param name="success">The handler called on the successful promise completion.</param>
        /// <param name="error">The handler is called if an error while completing the promise occurred.</param>
        /// <returns>The current promise.</returns>
        void Then(IResolvable next);

        /// <summary>
        /// Преобразует результат обещания к заданному типу и возвращает новое обещание.
        /// </summary>
        IPromise<T> Cast<T>();

        void Join();

        void Join(int timeout);
    }
}