This commit is contained in:
Михаил Капелько
2024-01-25 18:58:20 +03:00
parent 45e61ae350
commit 6886a049ae
3 changed files with 111 additions and 0 deletions

10
Modules/MicX/Mic/Mic.yml Normal file
View File

@@ -0,0 +1,10 @@
version: 2
model:
activityDates: [[String:Date], [:]]
service:
pipes:
activityDates: [recent, K.activityDates]
world:

View File

@@ -0,0 +1,100 @@
// ВНИМАНИЕ Сгенерировано автоматом из файла Mic.yml
// ВНИМАНИЕ Не менять руками!
import AELog
import BusX
import Combine
import Foundation
import MPAKX
import UIKit
// MARK: - Context
public protocol MicContext {
var activityDates: MPAK.Recent<[String:Date]> { 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 activityDates: MPAK.Recent<[String:Date]> = .init([:])
}
// 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
// MARK: - SectionGenerated Service Pipes
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 }
)
}
}
}

View File

@@ -38,6 +38,7 @@ struct Content: View {
class AppDelegate: UIResponder, UIApplicationDelegate
{
let meetupIS = MeetupId.Service(.init())
let micS = Mic.Service(.init())
var window: UIWindow?
func application(