1
1
@_spi ( Internals)
2
2
public struct IntrospectionSelector < Target: PlatformEntity > {
3
- private var receiver : ( IntrospectionPlatformViewController , IntrospectionAnchorID ) -> Target ?
4
- private var ancestor : ( IntrospectionPlatformViewController , IntrospectionAnchorID ) -> Target ?
3
+ private var receiverSelector : ( IntrospectionPlatformViewController , IntrospectionAnchorID ) -> Target ?
4
+ private var ancestorSelector : ( IntrospectionPlatformViewController , IntrospectionAnchorID ) -> Target ?
5
5
6
6
@_spi ( Internals)
7
7
public static var `default` : Self { . from( Target . self, selector: { $0 } ) }
8
8
9
+ @_spi ( Internals)
10
+ public func overrideAncestorSelector(
11
+ _ selector: @escaping ( PlatformViewController , IntrospectionAnchorID ) -> Target ?
12
+ ) -> Self {
13
+ var copy = self
14
+ copy. ancestorSelector = selector
15
+ return copy
16
+ }
17
+
9
18
@_spi ( Internals)
10
19
public static func from< Entry: PlatformEntity > ( _ entryType: Entry . Type , selector: @escaping ( Entry ) -> Target ? ) -> Self {
11
20
. init { controller, scope, anchorID in
@@ -45,11 +54,9 @@ public struct IntrospectionSelector<Target: PlatformEntity> {
45
54
}
46
55
}
47
56
48
- init (
49
- _ selector: @escaping ( IntrospectionPlatformViewController , IntrospectionScope , IntrospectionAnchorID ) -> Target ?
50
- ) {
51
- self . receiver = { selector ( $0, . receiver, $1) }
52
- self . ancestor = { selector ( $0, . ancestor, $1) }
57
+ init ( _ selector: @escaping ( IntrospectionPlatformViewController , IntrospectionScope , IntrospectionAnchorID ) -> Target ? ) {
58
+ self . receiverSelector = { selector ( $0, . receiver, $1) }
59
+ self . ancestorSelector = { selector ( $0, . ancestor, $1) }
53
60
}
54
61
55
62
func callAsFunction(
@@ -59,13 +66,13 @@ public struct IntrospectionSelector<Target: PlatformEntity> {
59
66
) -> Target ? {
60
67
if
61
68
scope. contains ( . receiver) ,
62
- let target = receiver ( controller, anchorID)
69
+ let target = receiverSelector ( controller, anchorID)
63
70
{
64
71
return target
65
72
}
66
73
if
67
74
scope. contains ( . ancestor) ,
68
- let target = ancestor ( controller, anchorID)
75
+ let target = ancestorSelector ( controller, anchorID)
69
76
{
70
77
return target
71
78
}
0 commit comments