diff --git a/Modules/MeetupIdX/MeetupId.yml b/Modules/MeetupIdX/MeetupId.yml index c670065..ad8e58d 100644 --- a/Modules/MeetupIdX/MeetupId.yml +++ b/Modules/MeetupIdX/MeetupId.yml @@ -5,6 +5,7 @@ model: isLoading: [Bool, false] join: [Bool, false] textUI: [String, ""] + testTextUI: [String, ""] service: actions: @@ -14,5 +15,6 @@ service: isLoading: [recent, K.isLoading] join: [toggle, K.join] textUI: [recent, K.textUI] + testTextUI: [many, K.testTextUI] world: diff --git a/Modules/MeetupIdX/src/MeetupId.Generated.swift b/Modules/MeetupIdX/src/MeetupId.Generated.swift index 8fe80f5..034037f 100644 --- a/Modules/MeetupIdX/src/MeetupId.Generated.swift +++ b/Modules/MeetupIdX/src/MeetupId.Generated.swift @@ -15,6 +15,7 @@ public protocol MeetupIdContext { var isLoading: MPAK.Recent { get } var join: Bool { get } var textUI: MPAK.Recent { get } + var testTextUI: MPAK.Many { get } } // MARK: - Controller @@ -39,6 +40,7 @@ extension MeetupId { public var isLoading: MPAK.Recent = .init(false) public var join: Bool = false public var textUI: MPAK.Recent = .init("") + public var testTextUI: MPAK.Many = .init() } // MARK: - Service @@ -142,6 +144,15 @@ extension MeetupId { ) + ctrl.pipeValue( + dbg: "testTUI", + sub: nil, + Bus.events.compactMap { Bus.convertKeyValue(K.testTextUI, $0) }.map { (k: String, v: MPAK.Many) in v }.eraseToAnyPublisher(), + { + $0.testTextUI = $1 + }, + { m, _ in m.testTextUI.keys = [] } + ) } diff --git a/Modules/MeetupIdX/src/MeetupId.SectionBus.swift b/Modules/MeetupIdX/src/MeetupId.SectionBus.swift index 84a4893..bed1719 100644 --- a/Modules/MeetupIdX/src/MeetupId.SectionBus.swift +++ b/Modules/MeetupIdX/src/MeetupId.SectionBus.swift @@ -12,6 +12,8 @@ extension MeetupId { Bus.Delay(shouldFinishLoading, 5, K.M, K.finishLoading), Bus.Sync(shouldEnableJoin, K.M, K.isJoinAvailable), Bus.Sync(shouldResetLoading, K.M, K.isLoading) + + Bus.Debounce(shouldManyResetText, 0.2, K.M, K.testTextApp), ]) } } diff --git a/Modules/MeetupIdX/src/MeetupId.Shoulds.swift b/Modules/MeetupIdX/src/MeetupId.Shoulds.swift index 2a2d4dc..22467a5 100644 --- a/Modules/MeetupIdX/src/MeetupId.Shoulds.swift +++ b/Modules/MeetupIdX/src/MeetupId.Shoulds.swift @@ -1,4 +1,5 @@ import Foundation +import MPAK public extension MeetupId { static func shouldEnableJoin(_ c: MeetupIdContext) -> Bool? { @@ -57,4 +58,17 @@ public extension MeetupId { guard c.textUI.isRecent else { return nil } return formatId(c.textUI.value) } + + // MARK: - Many + + static func shouldManyResetText(_ c: MeetupIdContext) -> MPAK.Many? { + guard !c.testTextUI.keys.isEmpty else { return nil } + var d = [String: String]() + for id in c.testTextUI.keys { + let text = c.testTextUI.dict[id] + d[id] = formatId(text) + } + return .init(c.testTextUI.keys, d) + } + }