mirror of
https://github.com/exyte/Macaw.git
synced 2024-09-11 05:05:23 +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 {
|
@discardableResult public func onTap(tapCount: Int = 1, f: @escaping (TapEvent) -> Void) -> Disposable {
|
||||||
let handler = ChangeHandler<TapEvent>(f)
|
let handler = ChangeHandler<TapEvent>(f)
|
||||||
if var handlers = tapHandlers[tapCount] {
|
|
||||||
handlers.append(handler)
|
var handlers = tapHandlers[tapCount] ?? []
|
||||||
} else {
|
handlers.append(handler)
|
||||||
tapHandlers[tapCount] = [handler]
|
|
||||||
}
|
tapHandlers[tapCount] = handlers
|
||||||
|
|
||||||
return Disposable { [weak self, unowned handler] in
|
return Disposable { [weak self, unowned handler] in
|
||||||
guard let index = self?.tapHandlers[tapCount]?.firstIndex(of: handler) else {
|
guard let index = self?.tapHandlers[tapCount]?.firstIndex(of: handler) else {
|
||||||
|
Loading…
Reference in New Issue
Block a user