0

For SWIFTUI i have created a ViewModifier to use the refreshable(action) view modifier available under iOS15. with this modifier I don't have to embed my all view in availability check.

It's seems to work properly, but I'm not confortable with the @Sendable and I wondering if there is some performance issue.

Do you think this is a good implementation?

struct RefreshView: ViewModifier {
    
    var action: @Sendable () async -> Void
    
    func body(content: Content) -> some View {
        if #available(iOS 15, *) {
            content.refreshable(action: action)
        } else {
            content
        }
    }
}

extension View {

func refreshView(action: @escaping @Sendable () async -> Void) -> some View {
        modifier(RefreshView(action: action))
    }
}
swordse
  • 1
  • 2
  • As phrased, this question is opinion-based and thus off-topic. If you have a _specific_ concern you've observed, please focus on that. You mention performance issues... are you concerned this code may take too long to run? How long is too long and what is an acceptable threshold? Are you concerned about memory usage? Same question. Be specific. See the [help] for more information. – TylerH Oct 27 '22 at 15:44

0 Answers0