Slide 14
Slide 14 text
UI*NQMFNFOUTTVCTDSJCFBOECJOE
extension ColorObservable {
public func subscribe(_ callback: @escaping (UIColor) -> Void) -> ColorObservation {
callback(value)
return ColorObservation(
notificationCenter.addObserver(forName: didChange, object: nil, queue: .main, using: { notification in
guard let value = notification.object as? UIColor else { return }
callback(value)
}),
notificationCenter: notificationCenter
)
}
public func bind(to object: O, keyPath: ReferenceWritableKeyPath) -> ColorObservation {
return subscribe { [weak object] value in
object?[keyPath: keyPath] = value
}
}
public func bind(to object: O, keyPath: ReferenceWritableKeyPath) -> ColorObservation {
return subscribe { [weak object] value in
object?[keyPath: keyPath] = value
}
}
}