1
1
mirror of https://github.com/exyte/Macaw.git synced 2024-08-15 16:10:39 +03:00

Fixed Node's onTap method. Previous implementation haven't considered copy on write behavior, so it was not possible to register second tap hander.

This commit is contained in:
Anton Poltoratskyi 2020-07-13 12:33:38 +03:00
parent cfb97d6f73
commit 6ba007b75e

View File

@ -111,11 +111,11 @@ open class Node: Drawable {
@discardableResult public func onTap(tapCount: Int = 1, f: @escaping (TapEvent) -> Void) -> Disposable {
let handler = ChangeHandler<TapEvent>(f)
if var handlers = tapHandlers[tapCount] {
handlers.append(handler)
} else {
tapHandlers[tapCount] = [handler]
}
var handlers = tapHandlers[tapCount] ?? []
handlers.append(handler)
tapHandlers[tapCount] = handlers
return Disposable { [weak self, unowned handler] in
guard let index = self?.tapHandlers[tapCount]?.firstIndex(of: handler) else {