Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Sources/Components/Tools/NamedDisplayCellNodeBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

import AsyncDisplayKit

fileprivate let queue = DispatchQueue.global()

/// An object from Abstract base class
///
/// This object sets name of object for accessibilityIdentifier
Expand All @@ -32,16 +30,17 @@ fileprivate let queue = DispatchQueue.global()
/// - Author: TetureSwiftSupport
open class NamedDisplayCellNodeBase: ASCellNode {

private var __actionHandlers: [(NamedDisplayCellNodeBase, DisplayNodeAction) -> Void] = []
private var __actionHandlers: [@MainActor (NamedDisplayCellNodeBase, DisplayNodeAction) -> Void] = []

@MainActor
open override func didLoad() {
super.didLoad()
#if DEBUG
queue.async { [weak self] in
Task.detached { [weak self] in
guard let self = self else { return }
let typeName = _typeName(type(of: self))
DispatchQueue.main.async {

Task { @MainActor in
guard self.accessibilityIdentifier == nil else { return }
self.accessibilityIdentifier = typeName
}
Expand All @@ -56,7 +55,7 @@ open class NamedDisplayCellNodeBase: ASCellNode {
- Warning: Non-atomic
*/
@discardableResult
public func addNodeActionHandler(_ handler: @escaping (Self, DisplayNodeAction) -> Void) -> Self {
public func addNodeActionHandler(_ handler: @escaping @MainActor (Self, DisplayNodeAction) -> Void) -> Self {
__actionHandlers.append { node, action in
guard let node = node as? Self else {
assertionFailure()
Expand All @@ -68,6 +67,7 @@ open class NamedDisplayCellNodeBase: ASCellNode {
return self
}

@MainActor
private func propagate(action: DisplayNodeAction) {
for handler in __actionHandlers {
handler(self, action)
Expand Down
13 changes: 5 additions & 8 deletions Sources/Components/Tools/NamedDisplayNodeBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

import AsyncDisplayKit

fileprivate let queue = DispatchQueue.global()

public enum DisplayNodeAction {
case didLoad
}
Expand All @@ -42,10 +40,10 @@ open class NamedDisplayNodeBase: ASDisplayNode {
open override func didLoad() {
super.didLoad()
#if DEBUG
queue.async { [weak self] in
Task.detached { [weak self] in
guard let self = self else { return }
let typeName = _typeName(type(of: self))
DispatchQueue.main.async {
Task { @MainActor in
guard self.accessibilityIdentifier == nil else { return }
self.accessibilityIdentifier = typeName
}
Expand All @@ -71,7 +69,6 @@ open class NamedDisplayNodeBase: ASDisplayNode {
return self
}

@preconcurrency
@MainActor
private func propagate(action: DisplayNodeAction) {
for handler in __actionHandlers {
Expand All @@ -96,10 +93,10 @@ open class NamedDisplayControlNodeBase: ASControlNode {
open override func didLoad() {
super.didLoad()
#if DEBUG
queue.async { [weak self] in
Task.detached { [weak self] in
guard let self = self else { return }
let typeName = _typeName(type(of: self))
DispatchQueue.main.async {
Task { @MainActor in
guard self.accessibilityIdentifier == nil else { return }
self.accessibilityIdentifier = typeName
}
Expand All @@ -113,7 +110,7 @@ open class NamedDisplayControlNodeBase: ASControlNode {
- Warning: Non-atomic
*/
@discardableResult
public func addNodeActionHandler(_ handler: @escaping (Self, DisplayNodeAction) -> Void) -> Self {
public func addNodeActionHandler(_ handler: @escaping @MainActor (Self, DisplayNodeAction) -> Void) -> Self {
__actionHandlers.append { node, action in
guard let node = node as? Self else {
assertionFailure()
Expand Down
Loading