Hi, i'm trying to use TCA for LazyVGrid, but here is issue with freezing, once you start using fast scroll or just scrolling grid fast. Once I remove send(action)
it works good. I'm sure i'm not using correctly. But looks like send action have issue with a lot of reducers.
in
.combined(with: Reducer<AssetModel, GalleryPhotoAction, GalleryPhotoEnvironment> { assetModel, action, environment in
switch action {
case .openPhoto:
return .none
case .downloadImage(let size, let asset):
return .none
case .setImage(let image):
assetModel.thumbnail = image
return .none
}
}.forEach(
state: \.galleryAssets,
action: /HomeAction.gallaryPhoto(id:action:),
environment: { GalleryPhotoEnvironment(photoLibraryService: $0.photoLibraryService) })
)
View
struct GalleryPhotoView: View {
let store: Store<AssetModel, GalleryPhotoAction>
var body: some View {
WithViewStore(store) { store in
let cellWidthHeight = screenSize.width/CGFloat(CELLS_IN_LINE)
let cellSize = CGSize(width: cellWidthHeight, height: cellWidthHeight)
GeometryReader {
if let thumbnail = store.thumbnail {
NavigationLink(destination: ResultView(input: .asset(store.state))) {
Image(uiImage: thumbnail)
.resizable()
.scaledToFill()
}
} else {
ProgressView()
.frame(width: $0.size.width, height: $0.size.height, alignment: .center)
}
}
.onAppear { store.send(.downloadImage(cellSize, store.asset)) }
.aspectRatio(1, contentMode: .fit)
.clipShape(RoundedRectangle(cornerRadius: 8, style: .continuous))
}
}
}