Files
check-ios-bus/Modules/MicX/Mic/src/Mic.Generated.swift
Михаил Капелько 1c864231ec d
2024-01-28 18:40:15 +03:00

141 lines
3.0 KiB
Swift
Raw Blame 히스토리

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// ВНИМАНИЕ Сгенерировано автоматом из файла Mic.yml
// ВНИМАНИЕ Не менять руками!
import AELog
import BusX
import Combine
import Foundation
import MPAKX
import UIKit
// MARK: - Context
public protocol MicContext {
var activeIds: MPAK.Recent<[String]> { get }
var activityDates: MPAK.Recent<[String:Date]> { get }
var requestActivityDate: String? { get }
}
// MARK: - Controller
extension Mic {
final class Controller: MPAK.Controller<Mic.Model> {
init() {
super.init(
Mic.Model(),
debugClassName: "MicCtrl",
debugLog: { aelog($0) }
)
}
}
// MARK: - Model
public struct Model: MicContext {
public var activeIds: MPAK.Recent<[String]> = .init([])
public var activityDates: MPAK.Recent<[String:Date]> = .init([:])
public var requestActivityDate: String? = nil
}
// MARK: - Service
public final class Service {
let ctrl = Controller()
let world: World
var subscriptions = [AnyCancellable]()
static private(set) weak var singleton: Service?
public init(_ world: World) {
self.world = world
Self.singleton = self
SectionGenerated.setupPlatform(ctrl, self, world)
}
}
// MARK: - World
public struct World {
public init(
) {
}
}
enum SectionGenerated {
// MARK: - SectionGenerated Service
static func setupPlatform(
_ ctrl: Controller,
_ service: Service,
_ world: World
) {
// MARK: - SectionGenerated Service Actions
ctrl.m
.compactMap { shouldDeliverActivityDates($0) }
.receive(on: DispatchQueue.main)
.sink { v in Bus.deliver(K.activityDate, v) }
.store(in: &service.subscriptions)
ctrl.m
.compactMap { shouldResetActivityDates($0) }
.receive(on: DispatchQueue.main)
.sink { v in Bus.send(K.activityDates, v) }
.store(in: &service.subscriptions)
// MARK: - SectionGenerated Service Pipes
ctrl.pipeValue(
dbg: "activeI",
sub: nil,
Bus.events.compactMap { Bus.convertKeyValue(K.activeIds, $0) }.map { (k: String, v: [String]) in v }.eraseToAnyPublisher(),
{
$0.activeIds.value = $1
$0.activeIds.isRecent = true
},
{ m, _ in m.activeIds.isRecent = false }
)
ctrl.pipeValue(
dbg: "activityD",
sub: nil,
Bus.events.compactMap { Bus.convertKeyValue(K.activityDates, $0) }.map { (k: String, v: [String:Date]) in v }.eraseToAnyPublisher(),
{
$0.activityDates.value = $1
$0.activityDates.isRecent = true
},
{ m, _ in m.activityDates.isRecent = false }
)
ctrl.pipeValue(
dbg: "requestAD",
sub: nil,
Bus.events.compactMap { Bus.convertKeyValue(K.requestActivityDate, $0) }.map { (k: String, v: String?) in v }.eraseToAnyPublisher(),
{ $0.requestActivityDate = $1 },
{ m, _ in m.requestActivityDate = nil }
)
}
}
}