Contents

donatedWithin(_:)

Filters donations to only those that occurred within the specified time range.

Declaration

func donatedWithin<DonationInfo>(_ timeRange: Tips.DonationTimeRange) -> [Self.Element] where DonationInfo : Decodable, DonationInfo : Encodable, DonationInfo : Sendable, Self.Element == Tips.Event<DonationInfo>.Donation

Parameters

  • timeRange:

    The time range to filter donations by.

Return Value

An array of donations that occurred within the given time range.

Discussion

Use this method inside a Tips/Rule predicate to constrain which donations are considered when evaluating tip eligibility.

#Rule(AppEvents.didLogin) {
    $0.donations.donatedWithin(.week).count >= 3
}