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 strategyURL
creation method takes precedence over theSortStrategy
that is specified over theService
.Declaration
Swift
case server(Sorter<K, V>, _: ((String, String) -> URLQueryItem)? = nil)
-
describes a
SortStrategy
client-sideDeclaration
Swift
case client(Sorter<K, V>)
-
describes none
SortStrategy
is needed.Declaration
Swift
case none
-
describes a
See moreSorter
with aDirection
(ascending, descending), theproperty
as aKeyPath
to 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