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 strategy URL creation method takes precedence over the SortStrategy that is specified over the Service.

    Declaration

    Swift

    case server(Sorter<K, V>, _: ((String, String) -> URLQueryItem)? = nil)
  • describes a SortStrategy client-side

    Declaration

    Swift

    case client(Sorter<K, V>)
  • describes none SortStrategy is needed.

    Declaration

    Swift

    case none
  • describes a Sorter with a Direction (ascending, descending), the property as a KeyPath to the later sorted variable of a class

    See more

    Declaration

    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