mirror of
https://github.com/exyte/Macaw.git
synced 2024-10-26 04:49:57 +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:
parent
cfb97d6f73
commit
6ba007b75e
@ -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] {
|
||||
|
||||
var handlers = tapHandlers[tapCount] ?? []
|
||||
handlers.append(handler)
|
||||
} else {
|
||||
tapHandlers[tapCount] = [handler]
|
||||
}
|
||||
|
||||
tapHandlers[tapCount] = handlers
|
||||
|
||||
return Disposable { [weak self, unowned handler] in
|
||||
guard let index = self?.tapHandlers[tapCount]?.firstIndex(of: handler) else {
|
||||
|
Loading…
Reference in New Issue
Block a user