SortStrategy
public enum SortStrategy<K, V> where K : Reflectable, K : Comparable, K : Decodable, K : Encodable, K : Hashable, K : Identifiable, V : Reflectable, V : ReflectionDecodable, V : Comparable, V : CustomStringConvertible, V : Decodable, V : Encodable
represents possible sorting strategies on the server, client or none strategy
How to define a FilterStrategy:
SortStrategy example:
basic structure:
.strategy(SortStrategy.Sorter(direction: .direction, property: KeyPath))
server example:
let serverStrategy = .server(SortStrategy.Sorter(direction: .asc, property: \Account.name))
defines a sort strategy where a fictional account class is sorted ascending by the name
-
specifies that the sorting process is realized through a server route; the user has the option to specify an own translation function in the case
Important
The configuration of an own server strategyURLcreation method takes precedence over theSortStrategythat is specified over theService.Declaration
Swift
case server(Sorter<K, V>, _: ((String, String) -> URLQueryItem)? = nil) -
describes a
SortStrategyclient-sideDeclaration
Swift
case client(Sorter<K, V>) -
describes none
SortStrategyis needed.Declaration
Swift
case none -
describes a
See moreSorterwith aDirection(ascending, descending), thepropertyas aKeyPathto the later sorted variable of a classDeclaration
Swift
public class Sorter<K, V> where K : Reflectable, K : Comparable, K : Decodable, K : Encodable, K : Hashable, K : Identifiable, V : Reflectable, V : ReflectionDecodable, V : Comparable, V : CustomStringConvertible, V : Decodable, V : Encodable
View on GitHub
SortStrategy Enumeration Reference