View on GitHub

mini-swift

Minimal Flux architecture written in Swift.

CLASS

Promise

public final class Promise<T>: PromiseType

Properties

result

public var result: Result<T, Swift.Error>?

Methods

value(_:)

public class func value(_ value: T) -> Promise<T>

error(_:)

public class func error(_ error: Swift.Error) -> Promise<T>

init(error:)

public init(error: Swift.Error)

init()

public init()

idle(with:)

public class func idle(with options: [String: Any] = [:]) -> Promise<T>

pending(options:)

public class func pending(options: [String: Any] = [:]) -> Promise<T>

fulfill(_:)

public func fulfill(_ value: T) -> Self
  • Note: fulfill do not trigger an object reassignment, so no notifications about it can be triggered. It is recommended to call the method notify afterwards.

reject(_:)

public func reject(_ error: Swift.Error) -> Self
  • Note: reject do not trigger an object reassignment, so no notifications about it can be triggered. It is recommended to call the method notify afterwards.

resolve(_:)

public func resolve(_ result: Result<T, Error>?) -> Self?

Resolves the current Promise with the optional Result parameter.

  • Returns: self or nil if no result was not provided.
  • Note: The optional parameter and restun value are helpers in order to make optional chaining in the Reducer context.