This commit is contained in:
Михаил Капелько
2023-12-29 13:11:32 +03:00
parent 860ac00106
commit bdeee67b38
5 changed files with 21 additions and 22 deletions

View File

@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = 'CordX'
s.version = '2023.12.28'
s.version = '2023.12.29'
s.license = 'IVCS'
s.summary = 'Упрощённое общение с шиной из SwiftUI'
s.homepage = 'IVCS'

View File

@@ -3,13 +3,13 @@ import Combine
extension Cord {
public final class Button: ObservableObject {
public let press = PassthroughSubject<Void, Never>()
public let v = PassthroughSubject<Void, Never>()
var subscriptions = [AnyCancellable]()
public init(_ key: String) {
Bus.send(
key,
press.eraseToAnyPublisher(),
v.eraseToAnyPublisher(),
sub: &subscriptions
)
}

View File

@@ -3,17 +3,17 @@ import Combine
extension Cord {
public final class Receive<T>: ObservableObject {
@Published public var value: T
@Published public var v: T
var subscriptions = [AnyCancellable]()
public init(
_ key: String,
_ defaultValue: T
) {
value = defaultValue
v = defaultValue
Bus.receive(
[key],
{ [weak self] (_, v: T) in self?.value = v },
{ [weak self] (_, v: T) in self?.v = v },
sub: &subscriptions
)
}

View File

@@ -4,7 +4,7 @@ import SwiftUI
extension Cord {
public final class TextField: ObservableObject {
@Published public var value = "a:"
@Published public var v = "a:"
var subscriptions = [AnyCancellable]()
public init(
@@ -13,7 +13,7 @@ extension Cord {
) {
Bus.send(
textUI,
$value
$v
.removeDuplicates()
.compactMap(onlyUIText)
.eraseToAnyPublisher(),
@@ -22,7 +22,7 @@ extension Cord {
Bus.receive(
[textApp],
{ [weak self] (_, v: String) in self?.value = "a:\(v)" },
{ [weak self] (_, v: String) in self?.v = "a:\(v)" },
sub: &subscriptions
)
}