d
This commit is contained in:
@@ -1,10 +1,14 @@
|
|||||||
version: 2
|
version: 2
|
||||||
|
|
||||||
model:
|
model:
|
||||||
|
activeIds: [[String], []]
|
||||||
activityDates: [[String:Date], [:]]
|
activityDates: [[String:Date], [:]]
|
||||||
|
|
||||||
service:
|
service:
|
||||||
|
actions:
|
||||||
|
shouldResetActivityDates: Bus.send(K.activityDates, v)
|
||||||
pipes:
|
pipes:
|
||||||
|
activeIds: [recent, K.activeIds]
|
||||||
activityDates: [recent, K.activityDates]
|
activityDates: [recent, K.activityDates]
|
||||||
|
|
||||||
world:
|
world:
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import UIKit
|
|||||||
// MARK: - Context
|
// MARK: - Context
|
||||||
|
|
||||||
public protocol MicContext {
|
public protocol MicContext {
|
||||||
|
var activeIds: MPAK.Recent<[String]> { get }
|
||||||
var activityDates: MPAK.Recent<[String:Date]> { get }
|
var activityDates: MPAK.Recent<[String:Date]> { get }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,6 +33,7 @@ extension Mic {
|
|||||||
// MARK: - Model
|
// MARK: - Model
|
||||||
|
|
||||||
public struct Model: MicContext {
|
public struct Model: MicContext {
|
||||||
|
public var activeIds: MPAK.Recent<[String]> = .init([])
|
||||||
public var activityDates: MPAK.Recent<[String:Date]> = .init([:])
|
public var activityDates: MPAK.Recent<[String:Date]> = .init([:])
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,10 +78,28 @@ extension Mic {
|
|||||||
) {
|
) {
|
||||||
// MARK: - SectionGenerated Service Actions
|
// MARK: - SectionGenerated Service Actions
|
||||||
|
|
||||||
|
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
|
// 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(
|
ctrl.pipeValue(
|
||||||
dbg: "activityD",
|
dbg: "activityD",
|
||||||
sub: nil,
|
sub: nil,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
public extension Mic {
|
public extension Mic {
|
||||||
enum K {
|
enum K {
|
||||||
|
public static let activeIds = "Mic.activeIds"
|
||||||
public static let activityDate = "Mic.activityDate"
|
public static let activityDate = "Mic.activityDate"
|
||||||
public static let activityDates = "Mic.activityDates"
|
public static let activityDates = "Mic.activityDates"
|
||||||
public static let isActive = "Mic.isActive"
|
public static let isActive = "Mic.isActive"
|
||||||
|
|||||||
12
Modules/MicX/Mic/src/Mic.Shoulds.swift
Normal file
12
Modules/MicX/Mic/src/Mic.Shoulds.swift
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
public extension Mic {
|
||||||
|
/// Следует обновить словарь состояний звуковой активности
|
||||||
|
///
|
||||||
|
/// Условия:
|
||||||
|
/// 1. ???
|
||||||
|
///
|
||||||
|
/// - Returns: Словарь активных состояний
|
||||||
|
static func shouldResetActivityDates(_ c: MicContext) -> [String: Date]? {
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -111,25 +111,17 @@ class AppDelegate: UIResponder, UIApplicationDelegate
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testMic4() {
|
func testMic4() {
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
|
delayedSend(2, Mic.K.activeIds, ["1"])
|
||||||
Bus.send(
|
delayedSend(4, Mic.K.activeIds, ["1", "4"])
|
||||||
Mic.K.activityDates,
|
}
|
||||||
[
|
|
||||||
"1": Date().addingTimeInterval(3),
|
|
||||||
"2": Date().addingTimeInterval(5),
|
|
||||||
]
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 4) {
|
func delayedSend(
|
||||||
Bus.send(
|
_ delay: TimeInterval,
|
||||||
Mic.K.activityDates,
|
_ key: String,
|
||||||
[
|
_ value: Any
|
||||||
"1": Date().addingTimeInterval(2),
|
) {
|
||||||
"4": Date().addingTimeInterval(5),
|
DispatchQueue.main.asyncAfter(deadline: .now() + delay) {
|
||||||
]
|
Bus.send(key, value)
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user