|
|
@@ -0,0 +1,130 @@ |
|
|
|
// ВНИМАНИЕ Сгенерировано автоматом из файла MicItem.yml |
|
|
|
// ВНИМАНИЕ Не менять руками! |
|
|
|
|
|
|
|
import AELog |
|
|
|
import BusX |
|
|
|
import Combine |
|
|
|
import Foundation |
|
|
|
import MPAKX |
|
|
|
import UIKit |
|
|
|
|
|
|
|
// MARK: - Context |
|
|
|
|
|
|
|
public protocol MicItemContext { |
|
|
|
var activityDates: MPAK.Recent<Date?> { get } |
|
|
|
var exReallyTest1: Bool? { get } |
|
|
|
var reallyTest1: Bool { get } |
|
|
|
var test2: Bool { get } |
|
|
|
var test3: Bool { get } |
|
|
|
var test4: Bool { get } |
|
|
|
var test5: MPAK.Recent<Bool> { get } |
|
|
|
var test6: MPAK.Recent<Bool> { get } |
|
|
|
var test7: MPAK.Recent<Bool> { get } |
|
|
|
var timeout: Bool { get } |
|
|
|
} |
|
|
|
|
|
|
|
extension MicItem { |
|
|
|
|
|
|
|
// MARK: - Model |
|
|
|
|
|
|
|
public struct Model: MicItemContext { |
|
|
|
public var activityDates: MPAK.Recent<Date?> = .init(nil) |
|
|
|
public var exReallyTest1: Bool? = nil |
|
|
|
public var reallyTest1: Bool = false |
|
|
|
public var test2: Bool = false |
|
|
|
public var test3: Bool = false |
|
|
|
public var test4: Bool = false |
|
|
|
public var test5: MPAK.Recent<Bool> = .init(false) |
|
|
|
public var test6: MPAK.Recent<Bool> = .init(false) |
|
|
|
public var test7: MPAK.Recent<Bool> = .init(false) |
|
|
|
public var timeout: Bool = false |
|
|
|
} |
|
|
|
|
|
|
|
// MARK: - Controller |
|
|
|
|
|
|
|
final class Controller: MPAK.Controller<MicItem.Model> { |
|
|
|
init(_ id: String? = nil) { |
|
|
|
var sid = "" |
|
|
|
if let id { |
|
|
|
sid = " : \(id)" |
|
|
|
} |
|
|
|
super.init( |
|
|
|
MicItem.Model(), |
|
|
|
debugClassName: "MicItemCtrl", |
|
|
|
debugLog: { aelog("\($0)\(sid)") } |
|
|
|
) |
|
|
|
|
|
|
|
// Отправляем модель в Шину. |
|
|
|
m |
|
|
|
.sink { v in Bus.send(Bus.keyId("MicItem", id), v) } |
|
|
|
.store(in: &subscriptions) |
|
|
|
|
|
|
|
pipeValue( |
|
|
|
dbg: "activityD", |
|
|
|
Bus.events.compactMap { Bus.convertKeyValue(Bus.keyId(K.activityDates, id), $0) }.map { (k: String, v: Date?) in v }.eraseToAnyPublisher(), |
|
|
|
{ |
|
|
|
$0.activityDates.value = $1 |
|
|
|
$0.activityDates.isRecent = true |
|
|
|
}, |
|
|
|
{ m, _ in m.activityDates.isRecent = false } |
|
|
|
) |
|
|
|
pipeValue( |
|
|
|
dbg: "reallyT", |
|
|
|
Bus.events.compactMap { Bus.convertKeyValue(Bus.keyId(K.reallyTest1, id), $0) }.map { (k: String, v: Bool) in v }.eraseToAnyPublisher(), |
|
|
|
{ |
|
|
|
$0.reallyTest1.value = $1 |
|
|
|
$0.reallyTest1.isRecent = true |
|
|
|
}, |
|
|
|
{ |
|
|
|
$0.reallyTest1.isRecent = false |
|
|
|
$0.exReallyTest1 = $1 |
|
|
|
} |
|
|
|
) |
|
|
|
pipeValue( |
|
|
|
dbg: "test2", |
|
|
|
Bus.events.compactMap { Bus.convertKeyValue(Bus.keyId(K.test2, id), $0) }.map { (k: String, v: Bool) in v }.eraseToAnyPublisher(), |
|
|
|
{ $0.test2 = $1 } |
|
|
|
) |
|
|
|
pipeValue( |
|
|
|
dbg: "test3", |
|
|
|
Bus.events.compactMap { Bus.convertKeyValue(Bus.keyId(K.test3, id), $0) }.map { (k: String, v: Bool) in v }.eraseToAnyPublisher(), |
|
|
|
{ $0.test3 = $1 }, |
|
|
|
{ m, _ in m.test3 = nil } |
|
|
|
) |
|
|
|
pipeValue( |
|
|
|
dbg: "test5", |
|
|
|
Bus.events.compactMap { Bus.convertKeyValue(Bus.keyId(D.test5, id), $0) }.map { (k: String, v: Bool) in v }.eraseToAnyPublisher(), |
|
|
|
{ |
|
|
|
$0.test5.value = $1 |
|
|
|
$0.test5.isRecent = true |
|
|
|
}, |
|
|
|
{ m, _ in m.test5.isRecent = false } |
|
|
|
) |
|
|
|
pipeValue( |
|
|
|
dbg: "test6", |
|
|
|
Bus.events.compactMap { Bus.convertKeyValue(Bus.keyId(K.abc, id), $0) }.map { (k: String, v: Bool) in v }.eraseToAnyPublisher(), |
|
|
|
{ |
|
|
|
$0.test6.value = $1 |
|
|
|
$0.test6.isRecent = true |
|
|
|
}, |
|
|
|
{ m, _ in m.test6.isRecent = false } |
|
|
|
) |
|
|
|
pipeValue( |
|
|
|
dbg: "test7", |
|
|
|
Bus.events.compactMap { Bus.convertKeyValue(Bus.keyId(D.def, id), $0) }.map { (k: String, v: Bool) in v }.eraseToAnyPublisher(), |
|
|
|
{ |
|
|
|
$0.test7.value = $1 |
|
|
|
$0.test7.isRecent = true |
|
|
|
}, |
|
|
|
{ m, _ in m.test7.isRecent = false } |
|
|
|
) |
|
|
|
pipe( |
|
|
|
dbg: "timeout", |
|
|
|
Bus.events.compactMap { Bus.convertKeyValue(Bus.keyId(K.timeout, id), $0) }.map { (k: String, v: Bool) in v }.eraseToAnyPublisher(), |
|
|
|
{ $0.timeout = true }, |
|
|
|
{ $0.timeout = false } |
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |