extension View { func task( priority: TaskPriority = .userInitiated, _ action: @Sendable @escaping () async -> Void ) -> some View { var task: Task<Void, Never>? return self .onAppear { task = Task(priority: priority) { await action() } } .onDisappear { task?.cancel() } } }
body
が走る度に走ってうまくいかなさそうな気がしてきた・・・。