Skip to content

Commit

Permalink
Make subpromises inherit the parent resolve queue
Browse files Browse the repository at this point in the history
  • Loading branch information
EricRabil committed Jul 25, 2022
1 parent 0c925ce commit 59c3d20
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Sources/Pwomise/Pwomise.swift
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ public class Promise<Output>: CustomDebugStringConvertible {
@discardableResult
public func always<R>(_ cb: @escaping (Completion) throws -> R) -> Promise<R> {
let promise = Promise<R>()
promise.resolveQueue = resolveQueue

listeners.append { result in
do {
Expand All @@ -216,6 +217,7 @@ public class Promise<Output>: CustomDebugStringConvertible {
@discardableResult
public func always<R: PromiseConvertible>(_ cb: @escaping (Completion) throws -> R) -> Promise<R.Output> {
let promise = Promise<R.Output>()
promise.resolveQueue = resolveQueue

listeners.append { result in
do {
Expand All @@ -234,6 +236,8 @@ public class Promise<Output>: CustomDebugStringConvertible {
@discardableResult
public func then<R: PromiseConvertible>(_ cb: @escaping (Output) throws -> R) -> Promise<R.Output> {
let promise = Promise<R.Output>()
promise.resolveQueue = resolveQueue

listeners.append { result in
do {
switch result {
Expand All @@ -256,6 +260,8 @@ public class Promise<Output>: CustomDebugStringConvertible {
@discardableResult
public func then<R>(_ cb: @escaping (Output) throws -> R) -> Promise<R> {
let promise = Promise<R>()
promise.resolveQueue = resolveQueue

listeners.append { result in
do {
switch result {
Expand All @@ -276,6 +282,8 @@ public class Promise<Output>: CustomDebugStringConvertible {
@discardableResult
public func `catch`<R: PromiseConvertible>(_ cb: @escaping (Error) throws -> R) -> Promise<R.Output> where R.Output == Output {
let promise = Promise<Output>()
promise.resolveQueue = resolveQueue

listeners.append { result in
do {
switch result {
Expand All @@ -298,6 +306,8 @@ public class Promise<Output>: CustomDebugStringConvertible {
@discardableResult
public func `catch`(_ cb: @escaping (Error) throws -> Output) -> Promise<Output> {
let promise = Promise<Output>()
promise.resolveQueue = resolveQueue

listeners.append { result in
do {
switch result {
Expand Down

0 comments on commit 59c3d20

Please sign in to comment.