Skip to content

Instantly share code, notes, and snippets.

@jpmartha
Created January 27, 2016 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpmartha/49b3215fb5d99bdf9aea to your computer and use it in GitHub Desktop.
Save jpmartha/49b3215fb5d99bdf9aea to your computer and use it in GitHub Desktop.
yashigani/Promise Documentation

Promise

Methods

  • state

    Declaration
    internal private(set) var state: State = .Pending

===

  • result

    Declaration
    internal private(set) var result: Result<T> = .Undefined

===

  • resolve

    Declaration
    private var resolve: (T -> Void)?

===

  • reject

    Declaration
    private var reject: (ErrorType -> Void)?

===

  • init(_:)

    Declaration
    public init(_ executor: (T -> Void, ErrorType -> Void) -> Void)

===

  • init(_:)

    Declaration
    public init(_ promise: Promise<T>)

===

  • init(_:)

    Declaration
    public convenience init(@autoclosure(escaping) _ executor: () throws -> T)

===

  • onFulfilled(_:)

    Declaration
    private func onFulfilled(value: T)

===

  • onRejected(_:)

    Declaration
    private func onRejected(error: ErrorType)

===

  • then(_:_:)

    Declaration
    private func then<U>(onFulfilled: T -> U, _ onRejected: (ErrorType -> Void)?) -> Promise<U>

===

  • then(_:_:)

    Declaration
    public func then<U>(onFulfilled: T -> U, _ onRejected: ErrorType -> Void) -> Promise<U>

===

  • then(_:)

    Declaration
    public func then<U>(onFulfilled: T -> U) -> Promise<U>

===

  • catch(_:)

    Declaration
    public func `catch`(onRejected: ErrorType -> Void) -> Promise<T>

===

  • MARK: static

===

  • all(_:)

    Declaration
    public static func all(promises: [Promise<T>]) -> Promise<[T]>

===

  • race(_:)

    Declaration
    public static func race(promises: [Promise<T>]) -> Promise<T>

===

  • resolve(_:)

    Declaration
    public static func resolve(value: T) -> Promise<T>

===

  • reject(_:)

    Declaration
    public static func reject(error: ErrorType) -> Promise<T>

===

Result

Declaration
internal enum Result<T> {
      case Undefined
      case Value(T)
      case Error(ErrorType)
  }

State

Declaration
internal enum State {
      case Pending
      case Fulfilled
      case Rejected
  }
@jpmartha
Copy link
Author

現状は Properties 未対応のため Methods に入っています。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment