ProductVM.swift 607 B

12345678910111213141516171819202122232425262728293031323334353637
  1. //
  2. // ProductVM.swift
  3. // SUIExamples
  4. //
  5. // Created by Pavel Yurchenko on 27.11.2024.
  6. //
  7. import SwiftUI
  8. @Observable
  9. final class ProductVM {
  10. struct Input {
  11. let id: Int
  12. }
  13. struct Output {
  14. var onProducts: Action?
  15. var onCart: Action?
  16. }
  17. let output: Output
  18. var objectId: Int
  19. private let input: Input
  20. init(input: Input, output: Output) {
  21. self.input = input
  22. self.output = output
  23. self.objectId = input.id
  24. DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
  25. self.objectId = input.id + 5
  26. }
  27. }
  28. }