Михаил Капелько 9 months ago
parent
commit
b63dbd4aab
1 changed files with 10 additions and 18 deletions
  1. +10
    -18
      Modules/MicX/MicItem/src/MicItem.WillBe.swift

Modules/MicX/MicItem/src/MicItem.Generated.swift → Modules/MicX/MicItem/src/MicItem.WillBe.swift View File

@@ -1,14 +1,5 @@
// ВНИМАНИЕ Сгенерировано автоматом из файла MicItem.yml
// ВНИМАНИЕ Не менять руками!

import AELog
import BusX import BusX
import Combine
import Foundation
import MPAKX import MPAKX
import UIKit

// MARK: - Context


public protocol MicItemContext { public protocol MicItemContext {
var activityDate: MPAK.Recent<Date?> { get } var activityDate: MPAK.Recent<Date?> { get }
@@ -16,16 +7,13 @@ public protocol MicItemContext {
} }


extension MicItem { extension MicItem {

// MARK: - Model

public struct Model: MicItemContext { public struct Model: MicItemContext {
public var activityDate: MPAK.Recent<Date?> = .init(nil) public var activityDate: MPAK.Recent<Date?> = .init(nil)
public var timeout: Bool = false public var timeout: Bool = false
} }
}


// MARK: - Controller

extension MicItem {
final class Controller: MPAK.Controller<MicItem.Model> { final class Controller: MPAK.Controller<MicItem.Model> {
init(_ id: String? = nil) { init(_ id: String? = nil) {
var sid = "" var sid = ""
@@ -34,17 +22,19 @@ extension MicItem {
} }
super.init( super.init(
MicItem.Model(), MicItem.Model(),
debugClassName: "MicItemCtrl",
debugLog: { aelog("\($0)\(sid)") }
debugClassName: "MicICtrl",
debugLog: { print("\($0)\(sid)") }
) )


// Отправляем модель в Шину.

// Нижеследующее предстоит сгенерить.
m m
.sink { v in Bus.send(Bus.keyId("MicItem", id), v) }
.sink { v in Bus.send(Bus.keyId(K.MI, id), v) }
.store(in: &subscriptions) .store(in: &subscriptions)


pipeValue( pipeValue(
dbg: "activityD", dbg: "activityD",
sub: nil,
Bus.events.compactMap { Bus.convertKeyValue(Bus.keyId(K.activityDate, id), $0) }.map { (k: String, v: Date?) in v }.eraseToAnyPublisher(), Bus.events.compactMap { Bus.convertKeyValue(Bus.keyId(K.activityDate, id), $0) }.map { (k: String, v: Date?) in v }.eraseToAnyPublisher(),
{ {
$0.activityDate.value = $1 $0.activityDate.value = $1
@@ -52,8 +42,10 @@ extension MicItem {
}, },
{ m, _ in m.activityDate.isRecent = false } { m, _ in m.activityDate.isRecent = false }
) )

pipe( pipe(
dbg: "timeout", dbg: "timeout",
sub: nil,
Bus.events.compactMap { Bus.convertKeyValue(Bus.keyId(K.timeout, id), $0) }.map { (k: String, v: Bool) in v }.eraseToAnyPublisher(), Bus.events.compactMap { Bus.convertKeyValue(Bus.keyId(K.timeout, id), $0) }.map { (k: String, v: Bool) in v }.eraseToAnyPublisher(),
{ $0.timeout = true }, { $0.timeout = true },
{ $0.timeout = false } { $0.timeout = false }

Loading…
Cancel
Save