Merge commit '7621e2f8dec938cf48181c8b10afc9b01f444e68' into beta

This commit is contained in:
Ilya Laktyushin
2025-12-06 02:17:48 +04:00
commit 8344b97e03
28070 changed files with 7995182 additions and 0 deletions
@@ -0,0 +1,39 @@
import Foundation
public final class ValuePipe<T> {
private let subscribers = Atomic(value: Bag<(T) -> Void>())
public init() {
}
public func signal() -> Signal<T, NoError> {
return Signal { [weak self] subscriber in
if let strongSelf = self {
let index = strongSelf.subscribers.with { value -> Bag<T>.Index in
return value.add { next in
subscriber.putNext(next)
}
}
return ActionDisposable { [weak strongSelf] in
if let strongSelf = strongSelf {
strongSelf.subscribers.with { value -> Void in
value.remove(index)
}
}
}
} else {
return EmptyDisposable
}
}
}
public func putNext(_ next: T) {
let items = self.subscribers.with { value -> [(T) -> Void] in
return value.copyItems()
}
for f in items {
f(next)
}
}
}