File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed
Sources/ComposableArchitecture/Effects
Tests/ComposableArchitectureTests Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,16 @@ extension EffectPublisher where Failure == Never {
8
8
public static func publisher< P: Publisher > ( _ createPublisher: @escaping ( ) -> P ) -> Self
9
9
where P. Output == Action , P. Failure == Never {
10
10
Self (
11
- operation: . publisher( Deferred ( createPublisher: createPublisher) . eraseToAnyPublisher ( ) )
11
+ operation: . publisher(
12
+ withEscapedDependencies { continuation in
13
+ Deferred {
14
+ continuation. yield {
15
+ createPublisher ( )
16
+ }
17
+ }
18
+ }
19
+ . eraseToAnyPublisher ( )
20
+ )
12
21
)
13
22
}
14
23
}
Original file line number Diff line number Diff line change
1
+ import Combine
2
+ import ComposableArchitecture
3
+ import XCTest
4
+
5
+ @MainActor
6
+ final class EffectPublisherTests : BaseTCATestCase {
7
+ var cancellables : Set < AnyCancellable > = [ ]
8
+
9
+ func testEscapedDependencies( ) {
10
+ @Dependency ( \. date. now) var now
11
+
12
+ let effect = withDependencies {
13
+ $0. date. now = Date ( timeIntervalSince1970: 1234567890 )
14
+ } operation: {
15
+ EffectTask . publisher {
16
+ Just ( now)
17
+ }
18
+ }
19
+
20
+ var value : Date ?
21
+ effect. sink { value = $0 } . store ( in: & self . cancellables)
22
+ XCTAssertEqual ( value, Date ( timeIntervalSince1970: 1234567890 ) )
23
+ }
24
+ }
You can’t perform that action at this time.
0 commit comments