Проверка шаблона шины для iOS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

165 lines
3.4KB

  1. // ВНИМАНИЕ Сгенерировано автоматом из файла MeetupId.yml
  2. // ВНИМАНИЕ Не менять руками!
  3. import AELog
  4. import BusX
  5. import Combine
  6. import Foundation
  7. import MPAKX
  8. import UIKit
  9. // MARK: - Context
  10. public protocol MeetupIdContext {
  11. var finishLoading: Bool { get }
  12. var isLoading: MPAK.Recent<Bool> { get }
  13. var join: Bool { get }
  14. var textUI: MPAK.Recent<String> { get }
  15. var testTextUI: MPAK.Many<String> { get }
  16. }
  17. // MARK: - Controller
  18. extension MeetupId {
  19. final class Controller: MPAK.Controller<MeetupId.Model> {
  20. init() {
  21. super.init(
  22. MeetupId.Model(),
  23. debugClassName: "MeetupICtrl",
  24. debugLog: { aelog($0) }
  25. )
  26. }
  27. }
  28. // MARK: - Model
  29. public struct Model: MeetupIdContext {
  30. public var finishLoading: Bool = false
  31. public var isLoading: MPAK.Recent<Bool> = .init(false)
  32. public var join: Bool = false
  33. public var textUI: MPAK.Recent<String> = .init("")
  34. public var testTextUI: MPAK.Many<String> = .init()
  35. }
  36. // MARK: - Service
  37. public final class Service {
  38. let ctrl = Controller()
  39. let world: World
  40. var any = [Any]()
  41. var subscriptions = [AnyCancellable]()
  42. static private(set) weak var singleton: Service?
  43. public init(_ world: World) {
  44. self.world = world
  45. Self.singleton = self
  46. SectionBus.setupService(ctrl, self, world)
  47. SectionGenerated.setupPlatform(ctrl, self, world)
  48. }
  49. }
  50. // MARK: - World
  51. public struct World {
  52. public init(
  53. ) {
  54. }
  55. }
  56. enum SectionGenerated {
  57. // MARK: - SectionGenerated Service
  58. static func setupPlatform(
  59. _ ctrl: Controller,
  60. _ service: Service,
  61. _ world: World
  62. ) {
  63. // MARK: - SectionGenerated Service Actions
  64. ctrl.m
  65. .sink { v in Bus.send("MeetupId", v) }
  66. .store(in: &service.subscriptions)
  67. // MARK: - SectionGenerated Service Pipes
  68. ctrl.pipe(
  69. dbg: "finishL",
  70. sub: nil,
  71. Bus.events.compactMap { Bus.convertKeyValue(K.finishLoading, $0) }.map { (k: String, v: Bool) in v }.eraseToAnyPublisher(),
  72. { $0.finishLoading = true },
  73. { $0.finishLoading = false }
  74. )
  75. ctrl.pipeValue(
  76. dbg: "isL",
  77. sub: nil,
  78. Bus.events.compactMap { Bus.convertKeyValue(K.isLoading, $0) }.map { (k: String, v: Bool) in v }.eraseToAnyPublisher(),
  79. {
  80. $0.isLoading.value = $1
  81. $0.isLoading.isRecent = true
  82. },
  83. { m, _ in m.isLoading.isRecent = false }
  84. )
  85. ctrl.pipe(
  86. dbg: "join",
  87. sub: nil,
  88. Bus.events.compactMap { Bus.convertKeyValue(K.join, $0) }.map { (k: String, v: Bool) in v }.eraseToAnyPublisher(),
  89. { $0.join = true },
  90. { $0.join = false }
  91. )
  92. ctrl.pipeValue(
  93. dbg: "textUI",
  94. sub: nil,
  95. Bus.events.compactMap { Bus.convertKeyValue(K.textUI, $0) }.map { (k: String, v: String) in v }.eraseToAnyPublisher(),
  96. {
  97. $0.textUI.value = $1
  98. $0.textUI.isRecent = true
  99. },
  100. { m, _ in m.textUI.isRecent = false }
  101. )
  102. ctrl.pipeValue(
  103. dbg: "testTUI",
  104. sub: nil,
  105. Bus.events.compactMap { Bus.convertKeyValue(K.testTextUI, $0) }.map { (k: String, v: MPAK.Many<String>) in v }.eraseToAnyPublisher(),
  106. {
  107. $0.testTextUI = $1
  108. },
  109. { m, _ in m.testTextUI.keys = [] }
  110. )
  111. }
  112. }
  113. }