|
- import Combine
- import Foundation
-
- enum MeetupId {
- enum Keys: String, RawRepresentable {
- case meetupIdTextApp
- case meetupIdTextUI
- }
-
- static func shouldFormat(_ s: String) -> String? {
- s.components(separatedBy: NSCharacterSet.decimalDigits.inverted).reduce("") { $0 + $1 }
- }
-
- final class MeetupIdFormatter {
- var subscriptions = Set<AnyCancellable>()
-
- deinit {
- print("ИГР MeetupIF.DEinit")
- }
-
- init() {
- Bus.receive(
- &subscriptions,
- [Keys.meetupIdTextUI.rawValue],
- { [weak self] k, v in self?.handleFormatting(k, v) }
- )
- print("ИГР MeetupIF.init")
- }
-
- func handleFormatting(_: String, _ value: String) {
- let out = MeetupId.shouldFormat(value)
- print("ИГР MeetupIF.handleF out/dt: '\(out)'/'\(Date())'")
- Bus.Service.singleton?.send(Keys.meetupIdTextApp.rawValue, out)
- }
- }
-
- }
|