2121
2222import AsyncDisplayKit
2323
24- fileprivate let queue = DispatchQueue . global ( )
25-
2624public enum DisplayNodeAction {
2725 case didLoad
2826}
@@ -42,10 +40,10 @@ open class NamedDisplayNodeBase: ASDisplayNode {
4240 open override func didLoad( ) {
4341 super. didLoad ( )
4442 #if DEBUG
45- queue . async { [ weak self] in
43+ Task . detached { [ weak self] in
4644 guard let self = self else { return }
4745 let typeName = _typeName ( type ( of: self ) )
48- DispatchQueue . main . async {
46+ Task { @ MainActor in
4947 guard self . accessibilityIdentifier == nil else { return }
5048 self . accessibilityIdentifier = typeName
5149 }
@@ -71,7 +69,6 @@ open class NamedDisplayNodeBase: ASDisplayNode {
7169 return self
7270 }
7371
74- @preconcurrency
7572 @MainActor
7673 private func propagate( action: DisplayNodeAction ) {
7774 for handler in __actionHandlers {
@@ -96,10 +93,10 @@ open class NamedDisplayControlNodeBase: ASControlNode {
9693 open override func didLoad( ) {
9794 super. didLoad ( )
9895 #if DEBUG
99- queue . async { [ weak self] in
96+ Task . detached { [ weak self] in
10097 guard let self = self else { return }
10198 let typeName = _typeName ( type ( of: self ) )
102- DispatchQueue . main . async {
99+ Task { @ MainActor in
103100 guard self . accessibilityIdentifier == nil else { return }
104101 self . accessibilityIdentifier = typeName
105102 }
@@ -113,7 +110,7 @@ open class NamedDisplayControlNodeBase: ASControlNode {
113110 - Warning: Non-atomic
114111 */
115112 @discardableResult
116- public func addNodeActionHandler( _ handler: @escaping ( Self , DisplayNodeAction ) -> Void ) -> Self {
113+ public func addNodeActionHandler( _ handler: @escaping @ MainActor ( Self , DisplayNodeAction ) -> Void ) -> Self {
117114 __actionHandlers. append { node, action in
118115 guard let node = node as? Self else {
119116 assertionFailure ( )
0 commit comments