Skip to content

Commit 6c046ce

Browse files
committed
wip
1 parent 8254af4 commit 6c046ce

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

Sources/IntrospectionSelector.swift

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ public struct IntrospectionSelector<Target: PlatformEntity> {
77
public static var `default`: Self { .from(Target.self, selector: { $0 }) }
88

99
@_spi(Internals)
10-
public func withAncestorSelector(
11-
_ selector: @escaping (PlatformViewController) -> Target?
12-
) -> Self {
10+
public func withReceiverSelector(_ selector: @escaping (PlatformViewController, IntrospectionAnchorID) -> Target?) -> Self {
11+
var copy = self
12+
copy.receiverSelector = selector
13+
return copy
14+
}
15+
16+
@_spi(Internals)
17+
public func withAncestorSelector(_ selector: @escaping (PlatformViewController) -> Target?) -> Self {
1318
var copy = self
1419
copy.ancestorSelector = selector
1520
return copy
@@ -18,21 +23,21 @@ public struct IntrospectionSelector<Target: PlatformEntity> {
1823
@_spi(Internals)
1924
public static func from<Entry: PlatformEntity>(_ entryType: Entry.Type, selector: @escaping (Entry) -> Target?) -> Self {
2025
.init(
21-
receiver: { controller, anchorID in
26+
receiverSelector: { controller, anchorID in
2227
controller.as(Entry.self)?.receiver(ofType: Entry.self, anchorID: anchorID).flatMap(selector)
2328
},
24-
ancestor: { controller in
29+
ancestorSelector: { controller in
2530
controller.as(Entry.self)?.ancestor(ofType: Entry.self).flatMap(selector)
2631
}
2732
)
2833
}
2934

3035
init(
31-
receiver: @escaping (IntrospectionPlatformViewController, IntrospectionAnchorID) -> Target?,
32-
ancestor: @escaping (IntrospectionPlatformViewController) -> Target?
36+
receiverSelector: @escaping (IntrospectionPlatformViewController, IntrospectionAnchorID) -> Target?,
37+
ancestorSelector: @escaping (IntrospectionPlatformViewController) -> Target?
3338
) {
34-
self.receiverSelector = receiver
35-
self.ancestorSelector = ancestor
39+
self.receiverSelector = receiverSelector
40+
self.ancestorSelector = ancestorSelector
3641
}
3742

3843
func callAsFunction(

0 commit comments

Comments
 (0)