This commit is contained in:
Михаил Капелько
2023-12-28 14:31:26 +03:00
parent 3583475da7
commit 5d5aa3d989
3 changed files with 27 additions and 3 deletions

View File

@@ -1,4 +1,18 @@
extension Bus { public extension Bus {
/// Пропускаем далее предоставленный ключ.
static func convertKeyValue<T>(
_ key: String,
_ v: (key: String, value: Any)
) -> (String, T)? {
guard
key == v.key,
let value = v.value as? T
else {
return nil
}
return (key, value)
}
/// Пропускаем далее предоставленные ключи. /// Пропускаем далее предоставленные ключи.
static func convertKeyValue<T>( static func convertKeyValue<T>(
_ keys: Set<String>, _ keys: Set<String>,

View File

@@ -7,6 +7,10 @@ public extension Bus {
enum Option { enum Option {
case async case async
} }
static var events: AnyPublisher<(key: String, value: Any), Never> {
Service.singleton.events.eraseToAnyPublisher()
}
} }
extension Bus { extension Bus {

View File

@@ -87,7 +87,10 @@ extension MeetupId {
ctrl.pipeValue( ctrl.pipeValue(
dbg: "textA", dbg: "textA",
sub: nil, sub: nil,
K.meetupIdTextApp.eraseToAnyPublisher(), Bus.events
.compactMap { Bus.convertKeyValue(K.meetupIdTextApp.rawValue, $0) }
.map { (k: String, v: String) -> String in v }
.eraseToAnyPublisher(),
{ {
$0.textApp.value = $1 $0.textApp.value = $1
$0.textApp.isRecent = true $0.textApp.isRecent = true
@@ -100,7 +103,10 @@ extension MeetupId {
ctrl.pipeValue( ctrl.pipeValue(
dbg: "textUI", dbg: "textUI",
sub: nil, sub: nil,
K.meetupIdTextUI.eraseToAnyPublisher(), Bus.events
.compactMap { Bus.convertKeyValue(K.meetupIdTextUI.rawValue, $0) }
.map { (k: String, v: String) -> String in v }
.eraseToAnyPublisher(),
{ {
$0.textUI.value = $1 $0.textUI.value = $1
$0.textUI.isRecent = true $0.textUI.isRecent = true