Post

Replies

Boosts

Views

Activity

Combine retain cycle created in .flatMap & Fail
This issue can be recreated by copying the below code into a playground. You will see that in the first example below the publisher is not released when using .flatMap with Fail import Combine import Foundation struct SampleError: Error {} weak var weakPublisher: CurrentValueSubjectSampleError, Never! autoreleasepool {   let publisher = CurrentValueSubjectSampleError, Never(SampleError())   weakPublisher = publisher       publisher     .flatMap(FailVoid, SampleError.init(error:))     .sink(       receiveCompletion: { print("completed \($0)") },       receiveValue: { print("value \($0)") }     )     .cancel() } assert(weakPublisher == nil, "should be nil BUT IS NOT !!!") In this second example, the publisher is released as expected using .tryMap with throw import Combine import Foundation struct SampleError: Error {} weak var weakPublisher2: CurrentValueSubjectSampleError, Never! autoreleasepool {   let publisher = CurrentValueSubjectSampleError, Never(SampleError())   weakPublisher2 = publisher       publisher     .tryMap{ throw $0 }     .sink(       receiveCompletion: { print("completed \($0)") },       receiveValue: { print("value \($0)") }     )     .cancel() } assert(weakPublisher2 == nil, "is nil as expected") Is this the expected behavior?
1
0
1.9k
Apr ’21
SwiftUI: Adding accessibility identifiers to VStack
The goal is to add accessibility identifiers to a VStack where the VStack, View1, and View2 have their own, separate accessibility identifiers set, like so:            VStack { // identifier a              View1 // identifier b              View2 // identifier c           } When trying to use .accessibilityIdentifier(identifier) with any SwiftUI Stack, the identifier is applied to everything inside the VStack and overrides any identifiers that View1 or View2 may have had. The current workaround is to use a GroupBox Container View to wrap the VStack. It achieves the desired result of having different levels of accessibility identifiers but has the drawback of coming with some styling (adds padding). Is there a better way to go about adding accessibility identifier to a container view? See Example playground - https://github.com/sparta-developers/swiftui-accessible-container
4
1
12k
Sep ’22
Combine retain cycle created in .flatMap & Fail
This issue can be recreated by copying the below code into a playground. You will see that in the first example below the publisher is not released when using .flatMap with Fail import Combine import Foundation struct SampleError: Error {} weak var weakPublisher: CurrentValueSubjectSampleError, Never! autoreleasepool {   let publisher = CurrentValueSubjectSampleError, Never(SampleError())   weakPublisher = publisher       publisher     .flatMap(FailVoid, SampleError.init(error:))     .sink(       receiveCompletion: { print("completed \($0)") },       receiveValue: { print("value \($0)") }     )     .cancel() } assert(weakPublisher == nil, "should be nil BUT IS NOT !!!") In this second example, the publisher is released as expected using .tryMap with throw import Combine import Foundation struct SampleError: Error {} weak var weakPublisher2: CurrentValueSubjectSampleError, Never! autoreleasepool {   let publisher = CurrentValueSubjectSampleError, Never(SampleError())   weakPublisher2 = publisher       publisher     .tryMap{ throw $0 }     .sink(       receiveCompletion: { print("completed \($0)") },       receiveValue: { print("value \($0)") }     )     .cancel() } assert(weakPublisher2 == nil, "is nil as expected") Is this the expected behavior?
Replies
1
Boosts
0
Views
1.9k
Activity
Apr ’21
SwiftUI: Adding accessibility identifiers to VStack
The goal is to add accessibility identifiers to a VStack where the VStack, View1, and View2 have their own, separate accessibility identifiers set, like so:            VStack { // identifier a              View1 // identifier b              View2 // identifier c           } When trying to use .accessibilityIdentifier(identifier) with any SwiftUI Stack, the identifier is applied to everything inside the VStack and overrides any identifiers that View1 or View2 may have had. The current workaround is to use a GroupBox Container View to wrap the VStack. It achieves the desired result of having different levels of accessibility identifiers but has the drawback of coming with some styling (adds padding). Is there a better way to go about adding accessibility identifier to a container view? See Example playground - https://github.com/sparta-developers/swiftui-accessible-container
Replies
4
Boosts
1
Views
12k
Activity
Sep ’22