Skip to content

Commit

Permalink
Add operator
Browse files Browse the repository at this point in the history
  • Loading branch information
woin2ee committed Oct 6, 2023
1 parent 4d05c72 commit e18ba93
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Sources/RxUtility/RxUtility.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,11 @@ extension PrimitiveSequenceType where Trait == CompletableTrait, Element == Neve
public func andThenJustNext() -> Single<Void> {
return self.andThen(.just(()))
}

public func catchAndThenJustNext() -> Single<Void> {
return self.primitiveSequence
.catch { _ in return .empty() }
.andThen(Single<Void>.just(()))
}

}
11 changes: 11 additions & 0 deletions Tests/RxUtilityTests/RxUtilityTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,16 @@ final class RxUtilityTests: XCTestCase {
// Assert
XCTAssertEqual(anyElement as? Int, 3)
}

func test_catchAndThenJustNext() throws {
// Arrange
let completableSequence: Completable = .error(TestingError.testingError)

// Act & Assert
try completableSequence
.catchAndThenJustNext()
.toBlocking()
.single()
}

}

0 comments on commit e18ba93

Please sign in to comment.