SwiftUI-Combine icon indicating copy to clipboard operation
SwiftUI-Combine copied to clipboard

Avatar Images are not loading

Open nagarajvrao opened this issue 5 years ago • 4 comments

Simulator ios version - 13.4

nagarajvrao avatar Apr 11 '20 06:04 nagarajvrao

Works fine without combine.

nagarajvrao avatar Apr 11 '20 14:04 nagarajvrao

Is it because datataskpublisher returns anycancellable which calls cancel() when deinitialized. In our case, cancel() is called when control leaves fetchImage()

nagarajvrao avatar Apr 12 '20 05:04 nagarajvrao

@nagarajvrao so, how to fix it? -.-😂

iHTCboy avatar Oct 10 '20 11:10 iHTCboy

This is working for me

// Add anycancellable
private var subscription = Set<AnyCancellable>()

// Add .store(in: &Set<AnyCancellable>) after .sink
.sink(receiveValue: { [weak self] image in
                self?.userImages[user] = image
            }).store(in: &subscription)

ChiouBo avatar Mar 09 '22 06:03 ChiouBo