Skip to content

Commit 2a24b97

Browse files
[PM-21602] Consolidate Combine things in BitwardenKit (#1577)
1 parent c94b81d commit 2a24b97

File tree

12 files changed

+28
-294
lines changed

12 files changed

+28
-294
lines changed

AuthenticatorBridgeKit/Publisher+Async.swift

Lines changed: 0 additions & 59 deletions
This file was deleted.

AuthenticatorShared/Core/Platform/Extentions/Future+Extensions.swift

Lines changed: 0 additions & 21 deletions
This file was deleted.

AuthenticatorShared/Core/Platform/Extentions/Publisher+Async.swift

Lines changed: 0 additions & 59 deletions
This file was deleted.

AuthenticatorShared/Core/Platform/Extentions/PublisherAsyncTests.swift

Lines changed: 0 additions & 60 deletions
This file was deleted.

AuthenticatorShared/Core/Platform/Extentions/SequenceAsyncTests.swift

Lines changed: 0 additions & 47 deletions
This file was deleted.

AuthenticatorBridgeKit/Future+Extensions.swift renamed to BitwardenKit/Core/Platform/Extensions/Future+Extensions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Combine
22

3-
extension Future {
3+
public extension Future {
44
/// Initialize a `Future` with an async throwing closure.
55
///
66
/// - Parameter attemptToFulfill: A closure that the publisher invokes when it emits a value or

BitwardenShared/Core/Platform/Extensions/Publisher+Async.swift renamed to BitwardenKit/Core/Platform/Extensions/Publisher+Async.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Combine
22

3-
extension Publisher {
3+
public extension Publisher {
44
/// Maps the output of a publisher to a different type, discarding any `nil` values.
55
///
66
/// - Parameters:
@@ -38,7 +38,7 @@ extension Publisher {
3838
}
3939
}
4040

41-
extension Publisher where Failure == Error {
41+
public extension Publisher where Failure == Error {
4242
/// Maps the output of a publisher to a different type which could throw an error.
4343
///
4444
/// - Parameters:

BitwardenShared/Core/Platform/Extensions/PublisherAsyncTests.swift renamed to BitwardenKit/Core/Platform/Extensions/PublisherAsyncTests.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1+
import BitwardenKit
12
import Combine
23
import XCTest
34

4-
@testable import BitwardenShared
5-
65
class PublisherAsyncTests: BitwardenTestCase {
76
// MARK: Properties
87

AuthenticatorShared/Core/Platform/Extentions/Sequence+Async.swift renamed to BitwardenKit/Core/Platform/Extensions/Sequence+Async.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22

3-
extension Sequence {
3+
public extension Sequence {
44
/// Performs an operation on each element of a sequence.
55
/// Each operation is performed serially in order.
66
///

BitwardenShared/Core/Auth/Repositories/Extensions/SequenceAsyncTests.swift renamed to BitwardenKit/Core/Platform/Extensions/SequenceAsyncTests.swift

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import XCTest
1+
import BitwardenKit
22

3-
@testable import BitwardenShared
3+
import XCTest
44

55
final class SequenceAsyncTests: BitwardenTestCase {
66
/// `asyncMap` correctly maps each element.
@@ -22,6 +22,27 @@ final class SequenceAsyncTests: BitwardenTestCase {
2222
}
2323
}
2424

25+
/// `asyncForEach` correctly performs a block with each element.
26+
func test_asyncForEach_success() async {
27+
let input = [1, 2, 3]
28+
var output: [Int] = []
29+
await input.asyncForEach { number in
30+
output.append(await asyncDouble(number))
31+
}
32+
XCTAssertEqual(output, [2, 4, 6])
33+
}
34+
35+
/// `asyncForEach` correctly propagates errors.
36+
func test_asyncForEach_error() async {
37+
let input = [1, 2, 3]
38+
var output: [Int] = []
39+
await assertAsyncThrows {
40+
try await input.asyncForEach { number in
41+
try output.append(await asyncDoubleWithError(number))
42+
}
43+
}
44+
}
45+
2546
/// Helper function to double a number asynchronously.
2647
///
2748
/// - Parameter number: an `Int` to double.

BitwardenShared/Core/Auth/Repositories/Extensions/Sequence+Async.swift

Lines changed: 0 additions & 19 deletions
This file was deleted.

BitwardenShared/Core/Platform/Extensions/Future+Extensions.swift

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)