-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
@mxcl What do you think of this syntax?
firstly {
login()
}.retainValue { username in
fetch(avatar: username)
}.retainValue { username, image in
resize(image)
}.then { username, original, resized in
…
}
you might consider adding the following functions
public func retainValue<U: Thenable>(on: DispatchQueue? = conf.Q.map, flags: DispatchWorkItemFlags? = nil, _ body: @escaping(Self.T) throws -> U) -> Promise<(T, U.T)> {
return then(on: on, flags: flags) { result in
try body(result).map(on: on, flags: flags) { (result, $0) }
}
}
/// tuple 2
public func retainValue<U: Thenable, V, W>(on: DispatchQueue? = conf.Q.map, flags: DispatchWorkItemFlags? = nil, _ body: @escaping(T) throws -> U) -> Promise<(V, W, U.T)> where T == (V, W) {
return then(on: on, flags: flags) { result in
try body(result).map(on: on, flags: flags) { (result.0, result.1, $0) }
}
}
/// tuple 3
public func retainValue<U: Thenable, V, W, X>(on: DispatchQueue? = conf.Q.map, flags: DispatchWorkItemFlags? = nil, _ body: @escaping(T) throws -> U) -> Promise<(V, W, X, U.T)> where T == (V, W, X) {
return then(on: on, flags: flags) { result in
try body(result).map(on: on, flags: flags) { (result.0, result.1, result.2, $0) }
}
}
Xcode 11.2.1
PromiseKit 6
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels