This commit is contained in:
Михаил Капелько
2023-12-28 15:46:33 +03:00
parent f27c52305d
commit 514e06e8fe
6 changed files with 22 additions and 14 deletions

View File

@@ -5,18 +5,18 @@ public extension Bus {
var subscriptions = [AnyCancellable]() var subscriptions = [AnyCancellable]()
public init( public init(
_ handler: @escaping ((Src) -> Dst?),
_ keyIn: String, _ keyIn: String,
_ keyOut: String, _ keyOut: String,
_ handler: @escaping ((Src) -> Dst?),
opt: [Option] = [] opt: [Option] = []
) { ) {
Bus.process([keyIn], keyOut, handler, opt: opt, sub: &subscriptions) Bus.process([keyIn], keyOut, handler, opt: opt, sub: &subscriptions)
} }
public init( public init(
_ handler: @escaping ((Src) -> Dst?),
_ keysIn: Set<String>, _ keysIn: Set<String>,
_ keyOut: String, _ keyOut: String,
_ handler: @escaping ((Src) -> Dst?),
opt: [Option] = [] opt: [Option] = []
) { ) {
Bus.process(keysIn, keyOut, handler, opt: opt, sub: &subscriptions) Bus.process(keysIn, keyOut, handler, opt: opt, sub: &subscriptions)

View File

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

View File

@@ -1,9 +1,10 @@
public extension MeetupId { public extension MeetupId {
enum K: String { enum K {
case meetupIdIsJoinAvailable static let isJoinAvailable = "MeetupId.isJoinAvailable"
case meetupIdJoin static let join = "MeetupId.join"
case meetupIdTextApp static let M = "MeetupId"
case meetupIdTextUI static let textApp = "MeetupId.textApp"
static let textUI = "MeetupId.textUI"
} }
} }

View File

@@ -0,0 +1,7 @@
import Foundation
public extension MeetupId {
static func shouldEnableJoin(_ c: MeetupIdContext) -> Bool? {
return nil
}
}

View File

@@ -4,10 +4,10 @@ import SwiftUI
extension MeetupId { extension MeetupId {
public struct V: View { public struct V: View {
@StateObject var isJA = Cord.Receive(K.meetupIdIsJoinAvailable.rawValue, false) @StateObject var isJA = Cord.Receive(K.isJoinAvailable, false)
@StateObject var join = Cord.Button(K.meetupIdJoin.rawValue) @StateObject var join = Cord.Button(K.join)
@StateObject var txtF = Cord.TextField(K.meetupIdTextApp.rawValue, K.meetupIdTextUI.rawValue) @StateObject var txtF = Cord.TextField(K.textApp, K.textUI)
let test = Bus.Processor(K.meetupIdTextUI.rawValue, K.meetupIdIsJoinAvailable.rawValue, onlyAllowJoin) let joinA = Bus.Processor(shouldEnableJoin, K.M, K.isJoinAvailable)
public init() { } public init() { }

View File

@@ -18,7 +18,7 @@ def pipeSource(name, entity, structure):
elif src.startswith("K."): elif src.startswith("K."):
busKey = src busKey = src
busValueType = structure.model.fields[name][0] busValueType = structure.model.fields[name][0]
src = "Bus.events.compactMap { Bus.convertKeyValue(" + busKey + ".rawValue, $0) }.map { (k: String, v: " + busValueType + ") in v }.eraseToAnyPublisher()" src = "Bus.events.compactMap { Bus.convertKeyValue(" + busKey + ", $0) }.map { (k: String, v: " + busValueType + ") in v }.eraseToAnyPublisher()"
# Значение по умолчанию. # Значение по умолчанию.
elif src == default: elif src == default:
return default + "." + name return default + "." + name