subscript(dynamicMember:)

Returns a read-only shared reference to the resulting value of a given key path.

Shared.swift:267
subscript<Member>(dynamicMember keyPath: KeyPath<Value, Member>) -> SharedReader<Member> { get }

Parameters

keyPath

A key path to a specific resulting value.

Returns

A new read-only shared reference.

You don’t call this subscript directly. Instead, Swift calls it for you when you access a property of the underlying value. In the following example, the property access $topics.count returns the value of invoking this subscript with \Set<Topic>.count:

@Shared var topics: Set<Topic>

$topics.count  // SharedReader<Int>