@@ -1,23 +1,23 @@ | |||||
import BusX | |||||
import Combine | import Combine | ||||
extension MeetupId { | |||||
public extension Bus { | |||||
final class Debounce<Src, Dst> { | final class Debounce<Src, Dst> { | ||||
let v = PassthroughSubject<Src, Never>() | let v = PassthroughSubject<Src, Never>() | ||||
var subscriptions = [AnyCancellable]() | var subscriptions = [AnyCancellable]() | ||||
init( | init( | ||||
_ sec: Double, | |||||
_ handler: @escaping ((Src) -> Dst?), | _ handler: @escaping ((Src) -> Dst?), | ||||
_ sec: Double, | |||||
_ src: String, | _ src: String, | ||||
_ dst: String | _ dst: String | ||||
) { | ) { | ||||
// Вход. | |||||
Bus.receiveSync( | Bus.receiveSync( | ||||
[src], | [src], | ||||
{ [weak self] _, v in self?.v.send(v) }, | { [weak self] _, v in self?.v.send(v) }, | ||||
&subscriptions | &subscriptions | ||||
) | ) | ||||
// Выход. | |||||
Bus.sendSync( | Bus.sendSync( | ||||
dst, | dst, | ||||
v | v |
@@ -1,23 +1,23 @@ | |||||
import BusX | |||||
import Combine | import Combine | ||||
extension MeetupId { | |||||
public extension Bus { | |||||
final class Delay<Src, Dst> { | final class Delay<Src, Dst> { | ||||
let v = PassthroughSubject<Src, Never>() | let v = PassthroughSubject<Src, Never>() | ||||
var subscriptions = [AnyCancellable]() | var subscriptions = [AnyCancellable]() | ||||
init( | init( | ||||
_ sec: Double, | |||||
_ handler: @escaping ((Src) -> Dst?), | _ handler: @escaping ((Src) -> Dst?), | ||||
_ sec: Double, | |||||
_ src: String, | _ src: String, | ||||
_ dst: String | _ dst: String | ||||
) { | ) { | ||||
// Вход. | |||||
Bus.receiveSync( | Bus.receiveSync( | ||||
[src], | [src], | ||||
{ [weak self] _, v in self?.v.send(v) }, | { [weak self] _, v in self?.v.send(v) }, | ||||
&subscriptions | &subscriptions | ||||
) | ) | ||||
// Выход. | |||||
Bus.sendSync( | Bus.sendSync( | ||||
dst, | dst, | ||||
v | v |
@@ -5,7 +5,7 @@ public extension Bus { | |||||
let v = PassthroughSubject<Src, Never>() | let v = PassthroughSubject<Src, Never>() | ||||
var subscriptions = [AnyCancellable]() | var subscriptions = [AnyCancellable]() | ||||
public init( | |||||
init( | |||||
_ handler: @escaping ((Src) -> Dst?), | _ handler: @escaping ((Src) -> Dst?), | ||||
_ src: String, | _ src: String, | ||||
_ dst: String | _ dst: String | ||||