Проверка шаблона шины для 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.

149 lines
2.9KB

  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. }
  16. // MARK: - Controller
  17. extension MeetupId {
  18. final class Controller: MPAK.Controller<MeetupId.Model> {
  19. init() {
  20. super.init(
  21. MeetupId.Model(),
  22. debugClassName: "MeetupICtrl",
  23. debugLog: { aelog($0) }
  24. )
  25. }
  26. }
  27. // MARK: - Model
  28. public struct Model: MeetupIdContext {
  29. public var finishLoading: Bool = false
  30. public var isLoading: MPAK.Recent<Bool> = .init(false)
  31. public var join: Bool = false
  32. public var textUI: MPAK.Recent<String> = .init("")
  33. }
  34. // MARK: - Service
  35. public final class Service {
  36. let ctrl = Controller()
  37. let world: World
  38. var subscriptions = [AnyCancellable]()
  39. static private(set) weak var singleton: Service?
  40. public init(_ world: World) {
  41. self.world = world
  42. Self.singleton = self
  43. SectionGenerated.setupPlatform(ctrl, self, world)
  44. }
  45. }
  46. // MARK: - World
  47. public struct World {
  48. public init(
  49. ) {
  50. }
  51. }
  52. enum SectionGenerated {
  53. // MARK: - SectionGenerated Service
  54. static func setupPlatform(
  55. _ ctrl: Controller,
  56. _ service: Service,
  57. _ world: World
  58. ) {
  59. // MARK: - SectionGenerated Service Actions
  60. ctrl.m
  61. .sink { v in Bus.send("MeetupId", v) }
  62. .store(in: &service.subscriptions)
  63. // MARK: - SectionGenerated Service Pipes
  64. ctrl.pipe(
  65. dbg: "finishL",
  66. sub: nil,
  67. Bus.events.compactMap { Bus.convertKeyValue(K.finishLoading, $0) }.map { (k: String, v: Bool) in v }.eraseToAnyPublisher(),
  68. { $0.finishLoading = true },
  69. { $0.finishLoading = false }
  70. )
  71. ctrl.pipeValue(
  72. dbg: "isL",
  73. sub: nil,
  74. Bus.events.compactMap { Bus.convertKeyValue(K.isLoading, $0) }.map { (k: String, v: Bool) in v }.eraseToAnyPublisher(),
  75. {
  76. $0.isLoading.value = $1
  77. $0.isLoading.isRecent = true
  78. },
  79. { m, _ in m.isLoading.isRecent = false }
  80. )
  81. ctrl.pipe(
  82. dbg: "join",
  83. sub: nil,
  84. Bus.events.compactMap { Bus.convertKeyValue(K.join, $0) }.map { (k: String, v: Bool) in v }.eraseToAnyPublisher(),
  85. { $0.join = true },
  86. { $0.join = false }
  87. )
  88. ctrl.pipeValue(
  89. dbg: "textUI",
  90. sub: nil,
  91. Bus.events.compactMap { Bus.convertKeyValue(K.textUI, $0) }.map { (k: String, v: String) in v }.eraseToAnyPublisher(),
  92. {
  93. $0.textUI.value = $1
  94. $0.textUI.isRecent = true
  95. },
  96. { m, _ in m.textUI.isRecent = false }
  97. )
  98. }
  99. }
  100. }