d
This commit is contained in:
@@ -5,6 +5,7 @@ model:
|
|||||||
isLoading: [Bool, false]
|
isLoading: [Bool, false]
|
||||||
join: [Bool, false]
|
join: [Bool, false]
|
||||||
textUI: [String, ""]
|
textUI: [String, ""]
|
||||||
|
testTextUI: [String, ""]
|
||||||
|
|
||||||
service:
|
service:
|
||||||
actions:
|
actions:
|
||||||
@@ -14,5 +15,6 @@ service:
|
|||||||
isLoading: [recent, K.isLoading]
|
isLoading: [recent, K.isLoading]
|
||||||
join: [toggle, K.join]
|
join: [toggle, K.join]
|
||||||
textUI: [recent, K.textUI]
|
textUI: [recent, K.textUI]
|
||||||
|
testTextUI: [many, K.testTextUI]
|
||||||
|
|
||||||
world:
|
world:
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ public protocol MeetupIdContext {
|
|||||||
var isLoading: MPAK.Recent<Bool> { get }
|
var isLoading: MPAK.Recent<Bool> { get }
|
||||||
var join: Bool { get }
|
var join: Bool { get }
|
||||||
var textUI: MPAK.Recent<String> { get }
|
var textUI: MPAK.Recent<String> { get }
|
||||||
|
var testTextUI: MPAK.Many<String> { get }
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Controller
|
// MARK: - Controller
|
||||||
@@ -39,6 +40,7 @@ extension MeetupId {
|
|||||||
public var isLoading: MPAK.Recent<Bool> = .init(false)
|
public var isLoading: MPAK.Recent<Bool> = .init(false)
|
||||||
public var join: Bool = false
|
public var join: Bool = false
|
||||||
public var textUI: MPAK.Recent<String> = .init("")
|
public var textUI: MPAK.Recent<String> = .init("")
|
||||||
|
public var testTextUI: MPAK.Many<String> = .init()
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Service
|
// 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<String>) in v }.eraseToAnyPublisher(),
|
||||||
|
{
|
||||||
|
$0.testTextUI = $1
|
||||||
|
},
|
||||||
|
{ m, _ in m.testTextUI.keys = [] }
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ extension MeetupId {
|
|||||||
Bus.Delay(shouldFinishLoading, 5, K.M, K.finishLoading),
|
Bus.Delay(shouldFinishLoading, 5, K.M, K.finishLoading),
|
||||||
Bus.Sync(shouldEnableJoin, K.M, K.isJoinAvailable),
|
Bus.Sync(shouldEnableJoin, K.M, K.isJoinAvailable),
|
||||||
Bus.Sync(shouldResetLoading, K.M, K.isLoading)
|
Bus.Sync(shouldResetLoading, K.M, K.isLoading)
|
||||||
|
|
||||||
|
Bus.Debounce(shouldManyResetText, 0.2, K.M, K.testTextApp),
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
import MPAK
|
||||||
|
|
||||||
public extension MeetupId {
|
public extension MeetupId {
|
||||||
static func shouldEnableJoin(_ c: MeetupIdContext) -> Bool? {
|
static func shouldEnableJoin(_ c: MeetupIdContext) -> Bool? {
|
||||||
@@ -57,4 +58,17 @@ public extension MeetupId {
|
|||||||
guard c.textUI.isRecent else { return nil }
|
guard c.textUI.isRecent else { return nil }
|
||||||
return formatId(c.textUI.value)
|
return formatId(c.textUI.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - Many
|
||||||
|
|
||||||
|
static func shouldManyResetText(_ c: MeetupIdContext) -> MPAK.Many<String>? {
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user